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 06:57olliecrowolliecrowScore: 4,205Success
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 07:024,17656,222,24721,369,00016,641,00094,662,656
2May 5, 2026 07:024,19455,293,73021,443,00016,728,00094,658,560
3May 5, 2026 07:024,19554,776,23521,446,00016,731,00094,666,752
4May 5, 2026 07:024,20454,885,80320,940,00017,317,00094,662,656
5May 5, 2026 07:024,20552,728,79021,461,00016,807,00094,662,656
6May 5, 2026 07:024,21253,309,88221,417,00016,915,00094,679,040
7May 5, 2026 07:024,21956,992,05721,495,00016,902,00094,670,848
8May 5, 2026 07:024,25253,631,43821,562,00017,138,00094,654,464
9May 5, 2026 07:024,26556,218,02621,140,00017,680,00094,670,848