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 listMay 18, 2026 08:13M-RochatM-RochatScore: 5,024Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 18, 2026 08:235,01354,842,34337,254,0008,370,00092,725,248
2May 18, 2026 08:235,02154,951,40337,305,0008,388,00092,753,920
3May 18, 2026 08:235,02254,763,07137,242,0008,463,00092,721,152
4May 18, 2026 08:235,02354,859,09137,291,0008,426,00092,667,904
5May 18, 2026 08:235,02455,788,49437,281,0008,444,00092,766,208
6May 18, 2026 08:235,02756,517,80737,241,0008,512,00092,745,728
7May 18, 2026 08:235,03554,981,48137,411,0008,412,00092,770,304
8May 18, 2026 08:235,03755,821,42137,323,0008,519,00092,717,056
9May 18, 2026 08:235,03854,986,96037,408,0008,443,00092,786,688