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 14, 2026 21:21Andrew EpsteinAndrew EpsteinScore: 3,760Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 14, 2026 21:283,73244,270,49225,373,0008,595,00092,712,960stderr
2Sep 14, 2026 21:283,74645,149,44125,442,0008,654,00092,766,208stderr
3Sep 14, 2026 21:283,75544,439,66425,498,0008,681,00092,758,016stderr
4Sep 14, 2026 21:283,75744,505,53725,623,0008,569,00092,737,536stderr
5Sep 14, 2026 21:283,76044,543,63425,526,0008,692,00092,782,592stderr
6Sep 14, 2026 21:283,76745,301,46925,674,0008,610,00092,741,632stderr
7Sep 14, 2026 21:283,83056,562,71026,314,0008,540,00092,733,440stderr
8Sep 14, 2026 21:283,85854,805,40126,480,0008,628,00092,790,784stderr
9Sep 14, 2026 21:283,87957,566,07026,596,0008,705,00092,807,168stderr