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 07:50Victor MerckléVictor MerckléScore: 2,685Success
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 07:562,67133,406,26515,578,0008,733,00092,749,824stderr
2Aug 19, 2026 07:562,67533,442,55715,601,0008,749,00092,786,688stderr
3Aug 19, 2026 07:562,67632,927,48415,628,0008,729,00092,741,632stderr
4Aug 19, 2026 07:562,68233,366,31415,676,0008,731,00092,758,016stderr
5Aug 19, 2026 07:562,68533,435,86115,678,0008,762,00092,798,976stderr
6Aug 19, 2026 07:562,69233,452,53515,697,0008,806,00092,782,592stderr
7Aug 19, 2026 07:562,70533,578,32615,726,0008,897,00092,733,440stderr
8Aug 19, 2026 07:562,71433,717,36215,796,0008,906,00092,721,152stderr
9Aug 19, 2026 07:562,71633,241,40615,811,0008,905,00092,749,824stderr