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 5, 2026 16:51Victor MerckléVictor MerckléScore: 2,865Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 5, 2026 16:572,84735,006,03817,287,0008,622,00092,680,192
2Jun 5, 2026 16:572,85135,082,71417,477,0008,471,00092,758,016
3Jun 5, 2026 16:572,86035,102,76017,516,0008,512,00092,811,264
4Jun 5, 2026 16:572,86535,123,49617,399,0008,673,00092,778,496
5Jun 5, 2026 16:572,86535,139,74117,533,0008,546,00092,737,536
6Jun 5, 2026 16:572,86635,152,56817,523,0008,560,00092,733,440
7Jun 5, 2026 16:572,86835,133,62817,533,0008,573,00092,733,440
8Jun 5, 2026 16:572,88335,210,23417,602,0008,635,00092,700,672
9Jun 5, 2026 16:572,88735,334,52717,633,0008,643,00092,733,440