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 10, 2026 18:55Josu San MartinJosu San MartinScore: 4,025Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 10, 2026 18:553,99557,934,61919,189,00017,169,00094,552,064
2Mar 10, 2026 18:553,99863,778,81319,202,00017,181,00094,552,064
3Mar 10, 2026 18:554,01162,699,40218,248,00018,248,00094,552,064
4Mar 10, 2026 18:554,01263,178,98620,282,00016,226,00094,666,752
5Mar 10, 2026 18:554,02566,391,29819,797,00016,827,00094,552,064
6Mar 10, 2026 18:554,02761,099,97819,807,00016,836,00094,552,064
7Mar 10, 2026 18:554,03962,607,00719,867,00016,887,00094,552,064
8Mar 10, 2026 18:554,04070,460,69616,891,00019,872,00094,695,424
9Mar 10, 2026 18:554,05463,370,24219,943,00016,952,00094,552,064