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 11, 2026 18:26Victor MerckléVictor MerckléScore: 2,710Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 11, 2026 18:312,68633,452,79915,601,0008,844,00092,798,976
2Jun 11, 2026 18:312,69033,487,34515,764,0008,722,00092,704,768
3Jun 11, 2026 18:312,69133,500,28915,768,0008,726,00092,782,592
4Jun 11, 2026 18:312,70533,622,84415,857,0008,763,00092,762,112
5Jun 11, 2026 18:312,71033,767,53915,885,0008,780,00092,733,440
6Jun 11, 2026 18:312,71133,658,68815,891,0008,783,00092,729,344
7Jun 11, 2026 18:312,71433,728,33415,705,0009,000,00092,758,016
8Jun 11, 2026 18:312,71733,762,25415,894,0008,836,00092,708,864
9Jun 11, 2026 18:312,72633,751,09815,934,0008,881,00092,708,864