XML to JSON Sergey Svistunov

Convert 1,000,000 person records from XML to JSON as fast as possible.

Input

XML document on STDIN:

<?xml version="1.0" encoding="UTF-8"?>
<persons>
    <person id="1512376">
        <age>30</age>
        <height>169.1</height>
        <married>true</married>
        <phone code="+6"><number>1283603279</number></phone>
        <phone code="+6"><number>1659964668</number></phone>
    </person>
    ...
</persons>

Output

One JSON object per person to STDOUT, preserving order:

{
    "id": 1512376,
    "age": 30,
    "height": 169.1,
    "married": true,
    "phones": [
        {
            "code": "+6",
            "number": 1283603279
        },
        {
            "code": "+6",
            "number": 1659964668
        }
    ]
}

Constraints

  • Preserve the order of persons
  • Omit the phones field if the phone array is empty
  • Maximum number of phones per person is 3
Back to listAug 16, 2026 00:18marko1597marko1597Score: 3,488Success
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 16, 2026 00:593,46439,843,63423,221,0008,303,00092,823,552stderr
2Aug 16, 2026 00:593,47839,972,39823,307,0008,348,00092,688,384stderr
3Aug 16, 2026 00:593,47940,682,07423,306,0008,353,00092,721,152stderr
4Aug 16, 2026 00:593,48140,109,91723,383,0008,297,00092,766,208stderr
5Aug 16, 2026 00:593,48840,064,64023,353,0008,396,00092,733,440stderr
6Aug 16, 2026 00:593,49040,101,73323,370,0008,398,00092,717,056stderr
7Aug 16, 2026 00:593,49240,199,78023,337,0008,448,00092,733,440stderr
8Aug 16, 2026 00:593,49940,959,55523,482,0008,360,00092,762,112stderr
9Aug 16, 2026 00:593,50940,356,61623,449,0008,489,00092,758,016stderr