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 listJun 11, 2026 03:06Victor MerckléVictor MerckléScore: 2,862Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 11, 2026 03:132,83635,295,07316,986,0008,830,00092,733,440
2Jun 11, 2026 03:132,83934,883,90117,011,0008,824,00092,745,728
3Jun 11, 2026 03:132,84035,184,36016,982,0008,865,00092,762,112
4Jun 11, 2026 03:132,84236,044,70117,004,0008,862,00092,786,688
5Jun 11, 2026 03:132,86236,231,70217,109,0008,943,00092,770,304
6Jun 11, 2026 03:132,86835,415,50116,978,0009,121,00092,753,920
7Jun 11, 2026 03:132,87033,708,94016,559,0009,562,00092,798,976
8Jun 11, 2026 03:132,87636,704,90717,164,0009,010,00092,749,824
9Jun 11, 2026 03:132,87936,244,60717,208,0008,999,00092,749,824