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:28M-RochatM-RochatScore: 5,608Success
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 06:485,59460,002,53542,639,0008,275,00092,712,960
2May 18, 2026 06:485,59560,138,06942,593,0008,322,00092,725,248
3May 18, 2026 06:485,60360,141,43942,676,0008,316,00092,786,688
4May 18, 2026 06:485,60562,055,74542,699,0008,311,00092,758,016
5May 18, 2026 06:485,60860,237,84542,640,0008,399,00092,729,344
6May 18, 2026 06:485,61160,682,39842,691,0008,377,00092,766,208
7May 18, 2026 06:485,61761,682,86642,652,0008,463,00092,786,688
8May 18, 2026 06:485,62060,253,43842,731,0008,412,00092,815,360
9May 18, 2026 06:485,62260,179,53742,746,0008,419,00092,774,400