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 4, 2026 02:09olliecrowolliecrowScore: 11,226Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 4, 2026 02:0911,185128,205,28983,825,00017,962,00094,572,544
2Mar 4, 2026 02:0911,193123,190,73286,875,00014,978,00094,547,968
3Mar 4, 2026 02:0911,206124,463,58884,983,00016,996,00094,650,368
4Mar 4, 2026 02:0911,210130,330,85987,008,00015,001,00094,543,872
5Mar 4, 2026 02:0911,226126,723,56487,134,00015,023,00094,552,064
6Mar 4, 2026 02:0911,234129,208,41184,192,00018,041,00094,679,040
7Mar 4, 2026 02:0911,434128,805,19684,038,00020,009,00094,543,872
8Mar 4, 2026 02:0911,498131,490,75085,696,00018,933,00094,699,520
9Mar 4, 2026 02:0911,580125,852,27084,504,00020,877,00094,568,448