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 listMay 16, 2026 18:21olliecrowolliecrowScore: 5,247Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 16, 2026 18:335,21856,197,74630,199,00017,292,00092,311,552
2May 16, 2026 18:335,23256,393,99330,300,00017,320,00092,315,648
3May 16, 2026 18:335,24256,897,18030,330,00017,377,00092,311,552
4May 16, 2026 18:335,24656,499,69130,304,00017,438,00092,311,552
5May 16, 2026 18:335,24756,411,56630,380,00017,375,00092,311,552
6May 16, 2026 18:335,24956,710,70230,323,00017,448,00092,311,552
7May 16, 2026 18:335,25756,699,09730,367,00017,472,00092,311,552
8May 16, 2026 18:335,25956,513,95130,376,00017,485,00092,311,552
9May 16, 2026 18:335,26956,712,24130,288,00017,666,00092,315,648