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 listJun 11, 2026 02:03Victor MerckléVictor MerckléError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 4, 2026 19:48Tomislav Tunkovic10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 4, 2026 20:00028,182,3718,643,0004,745,00041,824,256invalid character 'r' looking for beginning of value
2Sep 4, 2026 20:00023,072,9028,574,0004,831,00041,852,928invalid character 's' looking for beginning of value
3Sep 4, 2026 20:00023,785,6658,674,0004,547,00041,820,160invalid character 's' looking for beginning of value
4Jun 11, 2026 02:112,85035,032,21217,030,0008,912,00092,864,512
5Jun 11, 2026 02:112,85334,998,56717,040,0008,926,00092,807,168
6Jun 11, 2026 02:112,85934,878,34917,104,0008,914,00092,766,208
7Jun 11, 2026 02:112,86135,123,57617,105,0008,932,00092,741,632
8Jun 11, 2026 02:112,86335,058,58817,119,0008,941,00092,770,304
9Jun 11, 2026 02:112,86435,167,76417,084,0008,985,00092,708,864
10Jun 11, 2026 02:112,87035,295,71617,097,0009,023,00092,721,152
11Jun 11, 2026 02:112,87435,233,82817,112,0009,049,00092,692,480
12Jun 11, 2026 02:112,87935,188,73117,141,0009,064,00092,745,728