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 listAug 19, 2026 17:12Victor MerckléVictor MerckléScore: 2,391Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 19, 2026 17:242,37830,108,26213,098,0008,544,00092,745,728stderr
2Aug 19, 2026 17:242,38029,960,18012,900,0008,765,00092,696,576stderr
3Aug 19, 2026 17:242,38430,776,09013,134,0008,564,00092,741,632stderr
4Aug 19, 2026 17:242,39031,079,72613,123,0008,635,00092,758,016stderr
5Aug 19, 2026 17:242,39130,112,27712,897,0008,869,00092,684,288stderr
6Aug 19, 2026 17:242,39730,799,34613,287,0008,529,00092,737,536stderr
7Aug 19, 2026 17:242,40830,228,55213,194,0008,723,00092,753,920stderr
8Aug 19, 2026 17:242,40930,202,27713,158,0008,767,00092,745,728stderr
9Aug 19, 2026 17:242,41330,918,49213,276,0008,691,00092,745,728stderr