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 listSep 25, 2026 21:20Kevin HeaveyKevin HeaveyScore: 2,347Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 25, 2026 21:292,33830,048,17612,779,0008,504,00092,758,016
2Sep 25, 2026 21:292,33930,127,77012,858,0008,431,00092,766,208
3Sep 25, 2026 21:292,34030,056,44912,898,0008,404,00092,741,632
4Sep 25, 2026 21:292,34330,078,39712,927,0008,399,00092,766,208
5Sep 25, 2026 21:292,34730,159,97712,923,0008,438,00092,733,440
6Sep 25, 2026 21:292,34730,109,24512,950,0008,414,00092,712,960
7Sep 25, 2026 21:292,35030,503,08712,865,0008,528,00092,745,728
8Sep 25, 2026 21:292,35030,219,02112,947,0008,439,00092,766,208
9Sep 25, 2026 21:292,35830,286,16912,934,0008,529,00092,753,920