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 17, 2026 14:15Victor MerckléVictor MerckléScore: 2,592Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 17, 2026 14:242,56032,224,32914,774,0008,531,00092,737,536stderr
2Sep 17, 2026 14:242,58632,395,84014,830,0008,703,00092,696,576stderr
3Sep 17, 2026 14:242,58732,354,59614,965,0008,578,00092,717,056stderr
4Sep 17, 2026 14:242,58832,328,45114,982,0008,574,00092,794,880stderr
5Sep 17, 2026 14:242,59232,338,41814,854,0008,740,00092,745,728stderr
6Sep 17, 2026 14:242,59332,408,76014,892,0008,712,00092,758,016stderr
7Sep 17, 2026 14:242,59532,444,63914,973,0008,649,00092,798,976stderr
8Sep 17, 2026 14:242,60132,655,99014,828,0008,844,00092,729,344stderr
9Sep 17, 2026 14:242,60132,563,42514,959,0008,714,00092,667,904stderr