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 10, 2026 00:22Victor MerckléVictor MerckléScore: 2,828Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 10, 2026 00:282,80034,403,71916,834,0008,655,00092,766,208
2Jun 10, 2026 00:282,80034,414,82116,847,0008,635,00092,737,536
3Jun 10, 2026 00:282,80234,363,98516,856,0008,651,00092,741,632
4Jun 10, 2026 00:282,80634,505,73016,953,0008,582,00092,758,016
5Jun 10, 2026 00:282,82834,709,24216,980,0008,763,00092,762,112
6Jun 10, 2026 00:282,83235,143,76916,973,0008,805,00092,762,112
7Jun 10, 2026 00:282,83844,541,26016,917,0008,911,00092,729,344
8Jun 10, 2026 00:282,85046,729,12717,065,0008,870,00092,758,016
9Jun 10, 2026 00:282,86046,330,47617,214,0008,819,00092,766,208