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 17, 2026 06:45olliecrowolliecrowScore: 9,280Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 17, 2026 06:509,26094,162,74667,785,00016,487,00092,299,264
2May 17, 2026 06:509,27793,318,06967,780,00016,641,00092,299,264
3May 17, 2026 06:509,27795,285,05868,044,00016,381,00092,299,264
4May 17, 2026 06:509,27895,506,40467,854,00016,584,00092,299,264
5May 17, 2026 06:509,28093,262,96667,836,00016,617,00092,299,264
6May 17, 2026 06:509,28895,080,07967,848,00016,678,00092,299,264
7May 17, 2026 06:509,29093,389,69668,092,00016,450,00092,299,264
8May 17, 2026 06:509,29695,041,19368,257,00016,341,00092,299,264
9May 17, 2026 06:509,32994,771,18268,223,00016,675,00092,299,264