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:19M-RochatM-RochatScore: 5,530Success
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:355,52359,394,43841,953,0008,310,00092,733,440
2May 18, 2026 06:355,52562,398,83541,993,0008,293,00092,753,920
3May 18, 2026 06:355,52559,418,91941,918,0008,366,00092,782,592
4May 18, 2026 06:355,52759,339,64341,994,0008,305,00092,725,248
5May 18, 2026 06:355,53061,221,19042,040,0008,285,00092,766,208
6May 18, 2026 06:355,54359,647,09742,032,0008,418,00092,831,744
7May 18, 2026 06:355,54559,634,19642,165,0008,296,00092,741,632
8May 18, 2026 06:355,54762,828,97242,026,0008,453,00092,729,344
9May 18, 2026 06:355,55260,216,69342,068,0008,462,00092,717,056