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 5, 2026 04:15olliecrowolliecrowScore: 10,010Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 5, 2026 04:249,90798,294,41045,654,00044,506,00094,752,768
2May 5, 2026 04:249,96498,832,68545,671,00045,007,00094,691,328
3May 5, 2026 04:249,98298,917,40945,817,00045,028,00094,687,232
4May 5, 2026 04:249,98398,780,37446,566,00044,287,00094,711,808
5May 5, 2026 04:2410,01099,161,82946,456,00044,641,00094,720,000
6May 5, 2026 04:2410,01899,201,80146,517,00044,655,00094,736,384
7May 5, 2026 04:2410,08399,821,88145,227,00046,533,00094,760,960
8May 5, 2026 04:2410,108100,112,07545,657,00046,334,00094,773,248
9May 5, 2026 04:2410,176100,728,16846,505,00046,101,00094,707,712