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 15, 2026 16:31Victor MerckléVictor MerckléScore: 2,720Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 15, 2026 16:382,70533,309,50615,957,0008,664,00092,758,016stderr
2Sep 15, 2026 16:382,70633,388,79015,950,0008,679,00092,749,824stderr
3Sep 15, 2026 16:382,70633,326,36315,956,0008,671,00092,729,344stderr
4Sep 15, 2026 16:382,72033,460,70315,973,0008,785,00092,762,112stderr
5Sep 15, 2026 16:382,72033,456,72515,965,0008,790,00092,770,304stderr
6Sep 15, 2026 16:382,72133,520,28416,187,0008,575,00092,700,672stderr
7Sep 15, 2026 16:382,72434,156,56916,173,0008,622,00092,704,768stderr
8Sep 15, 2026 16:382,73033,559,09716,153,0008,699,00092,737,536stderr
9Sep 15, 2026 16:382,73533,605,47016,160,0008,733,00092,790,784stderr