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 10:03Victor MerckléVictor MerckléScore: 2,615Success
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 10:092,58732,030,77314,831,0008,715,00092,762,112stderr
2Aug 19, 2026 10:092,60532,679,90414,957,0008,757,00092,790,784stderr
3Aug 19, 2026 10:092,60632,100,27414,967,0008,754,00092,692,480stderr
4Aug 19, 2026 10:092,60932,141,62914,976,0008,772,00092,786,688stderr
5Aug 19, 2026 10:092,61532,183,88014,990,0008,811,00092,758,016stderr
6Aug 19, 2026 10:092,61832,852,34215,028,0008,797,00092,753,920stderr
7Aug 19, 2026 10:092,62133,047,99415,004,0008,854,00092,733,440stderr
8Aug 19, 2026 10:092,62532,263,67415,013,0008,881,00092,749,824stderr
9Aug 19, 2026 10:092,63432,334,49115,085,0008,889,00092,688,384stderr