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 08:00Victor MerckléVictor MerckléScore: 2,666Success
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 08:062,63332,391,97715,300,0008,664,00092,753,920stderr
2Aug 19, 2026 08:062,65033,231,63015,348,0008,775,00092,733,440stderr
3Aug 19, 2026 08:062,65432,459,70415,403,0008,751,00092,737,536stderr
4Aug 19, 2026 08:062,65633,207,86315,413,0008,757,00092,798,976stderr
5Aug 19, 2026 08:062,66633,270,42515,466,0008,801,00092,758,016stderr
6Aug 19, 2026 08:062,67832,690,13715,502,0008,869,00092,712,960stderr
7Aug 19, 2026 08:062,68133,353,59515,529,0008,874,00092,774,400stderr
8Aug 19, 2026 08:062,68533,425,48515,548,0008,891,00092,807,168stderr
9Aug 19, 2026 08:062,68633,440,83115,663,0008,786,00092,790,784stderr