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 listSep 15, 2026 08:06Victor MerckléVictor MerckléScore: 3,538Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 15, 2026 08:113,51740,440,30023,480,0008,527,00092,721,152stderr
2Sep 15, 2026 08:113,52540,555,23123,541,0008,542,00092,819,456stderr
3Sep 15, 2026 08:113,52841,417,54623,542,0008,569,00092,753,920stderr
4Sep 15, 2026 08:113,53640,734,06723,635,0008,544,00092,721,152stderr
5Sep 15, 2026 08:113,53840,657,24723,616,0008,581,00092,676,096stderr
6Sep 15, 2026 08:113,54140,803,13623,631,0008,600,00092,688,384stderr
7Sep 15, 2026 08:113,55240,794,11523,617,0008,712,00092,729,344stderr
8Sep 15, 2026 08:113,55640,962,01423,623,0008,738,00092,733,440stderr
9Sep 15, 2026 08:113,56041,726,60423,697,0008,705,00092,778,496stderr