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 07:38M-RochatM-RochatScore: 4,964Success
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:494,95656,516,90936,734,0008,371,00092,729,344
2May 18, 2026 07:494,95854,495,80336,806,0008,320,00092,762,112
3May 18, 2026 07:494,96254,340,94836,727,0008,428,00092,717,056
4May 18, 2026 07:494,96454,339,76136,827,0008,346,00092,717,056
5May 18, 2026 07:494,96454,393,16836,783,0008,395,00092,790,784
6May 18, 2026 07:494,97654,555,05436,862,0008,426,00092,766,208
7May 18, 2026 07:494,98154,589,70836,877,0008,457,00092,770,304
8May 18, 2026 07:494,98554,559,58336,853,0008,518,00092,762,112
9May 18, 2026 07:494,98554,983,86137,106,0008,266,00092,721,152