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:20M-RochatM-RochatScore: 4,975Success
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:334,95555,661,03836,769,0008,330,00092,733,440
2May 18, 2026 07:334,96954,281,71136,813,0008,409,00092,762,112
3May 18, 2026 07:334,97254,422,82436,816,0008,430,00092,672,000
4May 18, 2026 07:334,97355,423,97936,834,0008,426,00092,803,072
5May 18, 2026 07:334,97556,790,42236,948,0008,328,00092,737,536
6May 18, 2026 07:334,97654,821,83936,807,0008,476,00092,762,112
7May 18, 2026 07:334,97954,911,09336,837,0008,478,00092,712,960
8May 18, 2026 07:334,98054,628,61636,805,0008,517,00092,782,592
9May 18, 2026 07:334,98656,499,93336,969,0008,405,00092,758,016