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-RochatError
Source Code

Source code access is restricted. Log in to request access.

Challenge History
DateChallengerCostTypeStatus
Jul 6, 2026 10:00Victor Mercklé10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 6, 2026 10:01052,783,44334,818,0008,606,00092,893,184invalid character '<' after object key:value pair
2Jul 6, 2026 10:01052,601,09434,858,0008,350,00092,893,184invalid character '<' after object key:value pair
3Jul 6, 2026 10:01052,439,40734,814,0008,357,00092,893,184invalid character '<' after object key:value pair
4May 18, 2026 08:014,95556,408,96936,769,0008,327,00092,733,440
5May 18, 2026 08:014,96054,246,60536,796,0008,349,00092,745,728
6May 18, 2026 08:014,96257,351,69136,844,0008,317,00092,737,536
7May 18, 2026 08:014,96357,218,50736,667,0008,497,00092,774,400
8May 18, 2026 08:014,96954,795,40736,782,0008,436,00092,753,920
9May 18, 2026 08:014,97955,786,07436,834,0008,481,00092,794,880
10May 18, 2026 08:014,98354,485,36036,827,0008,526,00092,786,688
11May 18, 2026 08:014,99554,578,37837,007,0008,450,00092,729,344
12May 18, 2026 08:015,00254,676,41137,117,0008,407,00092,819,456