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 18, 2026 06:51M-RochatM-RochatScore: 5,474Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 18, 2026 07:055,45360,203,83441,338,0008,287,00092,749,824
2May 18, 2026 07:055,45558,792,95541,298,0008,351,00092,737,536
3May 18, 2026 07:055,46358,814,55141,369,0008,350,00092,741,632
4May 18, 2026 07:055,47159,610,08941,484,0008,305,00092,708,864
5May 18, 2026 07:055,47458,959,35141,392,0008,428,00092,741,632
6May 18, 2026 07:055,47559,179,19141,404,0008,427,00092,729,344
7May 18, 2026 07:055,47959,978,00041,418,0008,442,00092,790,784
8May 18, 2026 07:055,48561,081,90641,557,0008,360,00092,778,496
9May 18, 2026 07:055,49559,244,76641,626,0008,381,00092,729,344