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 16, 2026 13:03Victor MerckléVictor MerckléScore: 2,744Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 16, 2026 13:092,72833,560,50916,226,0008,604,00092,737,536stderr
2Sep 16, 2026 13:092,73034,192,29116,241,0008,610,00092,758,016stderr
3Sep 16, 2026 13:092,73533,577,80916,262,0008,634,00092,753,920stderr
4Sep 16, 2026 13:092,73733,853,09316,219,0008,691,00092,774,400stderr
5Sep 16, 2026 13:092,74433,736,04916,253,0008,720,00092,741,632stderr
6Sep 16, 2026 13:092,74633,995,48016,269,0008,726,00092,737,536stderr
7Sep 16, 2026 13:092,75333,763,15516,265,0008,788,00092,737,536stderr
8Sep 16, 2026 13:092,75433,738,69616,255,0008,810,00092,790,784stderr
9Sep 16, 2026 13:092,75733,844,01816,272,0008,823,00092,798,976stderr