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 18, 2026 15:09Victor MerckléVictor MerckléScore: 3,226Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 18, 2026 15:153,22039,218,70520,874,0008,428,00092,762,112stderr
2Aug 18, 2026 15:153,22439,166,79920,880,0008,460,00092,798,976stderr
3Aug 18, 2026 15:153,22440,490,53720,977,0008,367,00092,758,016stderr
4Aug 18, 2026 15:153,22539,165,89820,957,0008,397,00092,676,096stderr
5Aug 18, 2026 15:153,22639,204,60420,917,0008,441,00092,700,672stderr
6Aug 18, 2026 15:153,22839,309,09221,060,0008,322,00092,721,152stderr
7Aug 18, 2026 15:153,26639,487,78021,192,0008,532,00092,749,824stderr
8Aug 18, 2026 15:153,26939,695,55121,333,0008,420,00092,794,880stderr
9Aug 18, 2026 15:153,26939,562,40421,244,0008,509,00092,688,384stderr