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 listSep 17, 2026 14:03Victor MerckléVictor MerckléScore: 2,580Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 17, 2026 14:132,56732,156,61614,836,0008,527,00092,725,248stderr
2Sep 17, 2026 14:132,57232,186,41214,877,0008,532,00092,692,480stderr
3Sep 17, 2026 14:132,57332,235,14314,850,0008,565,00092,778,496stderr
4Sep 17, 2026 14:132,57832,246,07414,873,0008,592,00092,753,920stderr
5Sep 17, 2026 14:132,58033,019,70914,755,0008,727,00092,749,824stderr
6Sep 17, 2026 14:132,58032,345,24814,743,0008,738,00092,721,152stderr
7Sep 17, 2026 14:132,58532,351,55214,884,0008,648,00092,708,864stderr
8Sep 17, 2026 14:132,58932,324,88014,957,0008,605,00092,676,096stderr
9Sep 17, 2026 14:132,59332,400,63614,925,0008,674,00092,721,152stderr