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 04:48M-RochatM-RochatScore: 7,037Success
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 04:537,02373,067,29855,503,0008,408,00092,712,960
2May 18, 2026 04:537,02473,086,22355,475,0008,451,00092,774,400
3May 18, 2026 04:537,02673,186,10955,465,0008,473,00092,692,480
4May 18, 2026 04:537,03073,161,15255,571,0008,406,00092,749,824
5May 18, 2026 04:537,03773,283,58755,672,0008,373,00092,733,440
6May 18, 2026 04:537,04276,271,93655,561,0008,528,00092,733,440
7May 18, 2026 04:537,04475,142,71855,691,0008,416,00092,762,112
8May 18, 2026 04:537,05473,468,76355,793,0008,399,00092,737,536
9May 18, 2026 04:537,06176,857,83755,767,0008,490,00092,790,784