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 05:53olliecrowolliecrowScore: 4,222Success
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 05:594,19155,114,00921,621,00016,524,00094,670,848
2May 5, 2026 05:594,20454,612,34221,647,00016,618,00094,666,752
3May 5, 2026 05:594,21553,410,27821,652,00016,713,00094,654,464
4May 5, 2026 05:594,21755,602,51621,676,00016,699,00094,662,656
5May 5, 2026 05:594,22255,456,43021,638,00016,783,00094,666,752
6May 5, 2026 05:594,22354,868,57821,643,00016,788,00094,662,656
7May 5, 2026 05:594,24557,721,54721,716,00016,921,00094,658,560
8May 5, 2026 05:594,25655,504,08621,432,00017,304,00094,662,656
9May 5, 2026 05:594,27357,710,13921,356,00017,533,00094,662,656