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 listJan 18, 2026 07:15Josu San MartinJosu San MartinScore: 4,507Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jan 18, 2026 07:154,47065,768,54123,812,00016,867,00094,552,064
2Jan 18, 2026 07:154,47661,812,51324,835,00015,895,00094,552,064
3Jan 18, 2026 07:154,49167,376,66323,923,00016,945,00094,670,848
4Jan 18, 2026 07:154,49162,043,16022,928,00017,944,00094,674,944
5Jan 18, 2026 07:154,50768,519,06620,005,00021,005,00094,679,040
6Jan 18, 2026 07:154,50865,035,83424,012,00017,008,00094,666,752
7Jan 18, 2026 07:154,51167,779,85124,031,00017,022,00094,674,944
8Jan 18, 2026 07:154,51666,711,39823,052,00018,040,00094,674,944
9Jan 18, 2026 07:154,51863,850,86224,065,00017,046,00094,552,064