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:32Victor MerckléVictor MerckléScore: 2,708Success
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:372,68833,437,82915,764,0008,699,00092,758,016
2Jun 11, 2026 18:372,69633,500,89415,791,0008,745,00092,717,056
3Jun 11, 2026 18:372,70433,598,65415,860,0008,752,00092,774,400
4Jun 11, 2026 18:372,70833,658,28015,874,0008,773,00092,762,112
5Jun 11, 2026 18:372,70833,642,80915,864,0008,780,00092,758,016
6Jun 11, 2026 18:372,71133,665,38715,863,0008,811,00092,737,536
7Jun 11, 2026 18:372,71233,677,78715,833,0008,853,00092,733,440
8Jun 11, 2026 18:372,71233,679,11515,842,0008,838,00092,786,688
9Jun 11, 2026 18:372,72534,053,67815,928,0008,873,00092,766,208