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:22Victor MerckléVictor MerckléScore: 2,627Success
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:282,57732,573,40914,781,0008,678,00092,745,728stderr
2Aug 19, 2026 09:282,58632,755,00814,835,0008,703,00092,745,728stderr
3Aug 19, 2026 09:282,60432,139,75014,913,0008,788,00092,803,072stderr
4Aug 19, 2026 09:282,60832,813,30914,924,0008,811,00092,766,208stderr
5Aug 19, 2026 09:282,62738,727,29615,187,0008,726,00092,741,632stderr
6Aug 19, 2026 09:282,62732,203,59715,021,0008,886,00092,758,016stderr
7Aug 19, 2026 09:282,62832,888,79015,025,0008,892,00092,803,072stderr
8Aug 19, 2026 09:282,62939,833,74515,217,0008,710,00092,737,536stderr
9Aug 19, 2026 09:282,66040,065,32415,337,0008,871,00092,786,688stderr