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 19, 2026 09:05Victor MerckléVictor MerckléScore: 2,640Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 19, 2026 09:112,63232,951,07515,233,0008,725,00092,725,248stderr
2Aug 19, 2026 09:112,63333,098,28515,213,0008,750,00092,774,400stderr
3Aug 19, 2026 09:112,63833,108,25715,261,0008,750,00092,782,592stderr
4Aug 19, 2026 09:112,63833,021,38815,264,0008,747,00092,786,688stderr
5Aug 19, 2026 09:112,64033,163,57315,237,0008,791,00092,737,536stderr
6Aug 19, 2026 09:112,64633,186,33315,294,0008,789,00092,745,728stderr
7Aug 19, 2026 09:112,66233,237,02015,354,0008,877,00092,729,344stderr
8Aug 19, 2026 09:112,66433,279,53715,372,0008,875,00092,725,248stderr
9Aug 19, 2026 09:112,67133,312,05015,427,0008,887,00092,758,016stderr