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 listMay 7, 2026 09:15Victor MerckléVictor MerckléScore: 50,009Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 7, 2026 09:2049,986470,815,554437,582,00017,299,00094,801,920stderr
2May 7, 2026 09:2049,989471,121,883438,623,00016,278,00094,781,440stderr
3May 7, 2026 09:2049,995470,671,673438,540,00016,420,00094,789,632stderr
4May 7, 2026 09:2049,998474,619,916437,742,00017,246,00094,781,440stderr
5May 7, 2026 09:2050,009473,828,930438,117,00016,969,00094,777,344stderr
6May 7, 2026 09:2050,048471,586,749438,033,00017,409,00094,806,016stderr
7May 7, 2026 09:2050,052471,609,804438,049,00017,431,00094,781,440stderr
8May 7, 2026 09:2050,164473,365,021439,068,00017,428,00094,777,344stderr
9May 7, 2026 09:2050,334474,991,332440,650,00017,398,00094,777,344stderr