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 13:31Kevin HeaveyKevin HeaveyScore: 2,353Success
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 13:362,34730,099,69212,958,0008,401,00092,737,536
2Sep 25, 2026 13:362,35030,207,76012,988,0008,402,00092,778,496
3Sep 25, 2026 13:362,35130,080,98012,966,0008,430,00092,741,632
4Sep 25, 2026 13:362,35330,189,55012,957,0008,456,00092,712,960
5Sep 25, 2026 13:362,35330,074,11712,971,0008,444,00092,721,152
6Sep 25, 2026 13:362,36230,250,91012,848,0008,652,00092,758,016
7Sep 25, 2026 13:362,36730,286,29713,094,0008,452,00092,680,192
8Sep 25, 2026 13:362,38330,536,19113,121,0008,572,00092,782,592
9Sep 25, 2026 13:362,38930,487,54113,169,0008,574,00092,741,632