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 15:39Victor MerckléVictor MerckléScore: 2,408Success
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 15:452,37030,018,47512,889,0008,680,00092,770,304stderr
2Aug 19, 2026 15:452,40430,682,80513,216,0008,663,00092,770,304stderr
3Aug 19, 2026 15:452,40430,154,48313,072,0008,809,00092,782,592stderr
4Aug 19, 2026 15:452,40430,161,70813,102,0008,779,00092,823,552stderr
5Aug 19, 2026 15:452,40830,370,24513,392,0008,527,00092,778,496stderr
6Aug 19, 2026 15:452,40930,218,07313,207,0008,720,00092,704,768stderr
7Aug 19, 2026 15:452,41030,327,88113,125,0008,815,00092,737,536stderr
8Aug 19, 2026 15:452,41830,620,72913,032,0008,974,00092,745,728stderr
9Aug 19, 2026 15:452,42230,195,67413,138,0008,903,00092,758,016stderr