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 listMar 21, 2026 11:28olliecrowolliecrowScore: 5,206Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 20, 2026 00:025,15669,465,10224,960,00021,964,00094,552,064
2Mar 20, 2026 00:025,18369,769,30126,090,00021,073,00094,552,064
3Mar 20, 2026 00:025,18371,793,42626,092,00021,074,00094,539,776
4Mar 20, 2026 00:025,18973,037,12325,117,00022,103,00094,552,064
5Mar 21, 2026 11:285,19068,835,89625,123,00022,109,00094,552,064
6Mar 20, 2026 00:025,19878,175,81527,175,00020,130,00094,552,064
7Mar 20, 2026 00:025,20669,838,51726,206,00021,167,00094,552,064
8Mar 20, 2026 00:025,20875,944,92826,220,00021,177,00094,543,872
9Mar 20, 2026 00:025,20972,019,42029,248,00018,154,00094,543,872
10Mar 21, 2026 11:285,21674,996,71828,277,00019,188,00094,552,064
11Mar 20, 2026 00:025,22272,058,44430,333,00017,188,00094,552,064
12Mar 21, 2026 11:285,23778,024,21928,792,00018,863,00094,543,872