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:49M-RochatM-RochatScore: 4,969Success
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 08:014,95556,408,96936,769,0008,327,00092,733,440
2May 18, 2026 08:014,96054,246,60536,796,0008,349,00092,745,728
3May 18, 2026 08:014,96257,351,69136,844,0008,317,00092,737,536
4May 18, 2026 08:014,96357,218,50736,667,0008,497,00092,774,400
5May 18, 2026 08:014,96954,795,40736,782,0008,436,00092,753,920
6May 18, 2026 08:014,97955,786,07436,834,0008,481,00092,794,880
7May 18, 2026 08:014,98354,485,36036,827,0008,526,00092,786,688
8May 18, 2026 08:014,99554,578,37837,007,0008,450,00092,729,344
9May 18, 2026 08:015,00254,676,41137,117,0008,407,00092,819,456