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 listJul 7, 2026 20:03Victor MerckléVictor MerckléScore: 2,779Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 7, 2026 20:092,76635,393,89516,599,0008,572,00092,729,344stderr
2Jul 7, 2026 20:092,77434,907,38816,437,0008,810,00092,782,592stderr
3Jul 7, 2026 20:092,77734,850,42916,553,0008,725,00092,798,976stderr
4Jul 7, 2026 20:092,77734,966,37116,524,0008,754,00092,737,536stderr
5Jul 7, 2026 20:092,77934,925,89716,662,0008,635,00092,721,152stderr
6Jul 7, 2026 20:092,79235,094,04216,612,0008,802,00092,721,152stderr
7Jul 7, 2026 20:092,79535,066,10616,658,0008,778,00092,786,688stderr
8Jul 7, 2026 20:092,79635,604,89516,644,0008,806,00092,766,208stderr
9Jul 7, 2026 20:092,81435,721,40816,745,0008,867,00092,786,688stderr