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 4, 2026 07:39Victor MerckléVictor MerckléScore: 2,823Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 4, 2026 07:482,81433,953,36116,443,0009,171,00092,758,016stderr
2Sep 4, 2026 07:482,81434,622,44216,397,0009,211,00092,692,480stderr
3Sep 4, 2026 07:482,81934,157,91116,402,0009,254,00092,733,440stderr
4Sep 4, 2026 07:482,82034,995,39516,458,0009,213,00092,782,592stderr
5Sep 4, 2026 07:482,82334,070,32216,431,0009,259,00092,778,496stderr
6Sep 4, 2026 07:482,83034,867,29816,482,0009,280,00092,811,264stderr
7Sep 4, 2026 07:482,84034,860,26616,527,0009,325,00092,753,920stderr
8Sep 4, 2026 07:482,84834,468,62116,472,0009,448,00092,737,536stderr
9Sep 4, 2026 07:482,86335,165,34916,712,0009,348,00092,737,536stderr