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 26, 2026 20:07Kevin HeaveyKevin HeaveyScore: 2,359Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 26, 2026 20:132,33829,966,21012,858,0008,422,00092,721,152
2Sep 26, 2026 20:132,34229,981,31912,868,0008,448,00092,749,824
3Sep 26, 2026 20:132,34630,008,18412,884,0008,468,00092,770,304
4Sep 26, 2026 20:132,35030,010,69912,850,0008,544,00092,794,880
5Sep 26, 2026 20:132,35930,021,78713,043,0008,427,00092,745,728
6Sep 26, 2026 20:132,36230,104,98513,012,0008,491,00092,790,784
7Sep 26, 2026 20:132,36330,131,97213,064,0008,440,00092,819,456
8Sep 26, 2026 20:132,37330,226,51313,019,0008,577,00092,758,016
9Sep 26, 2026 20:132,39230,368,35013,174,0008,595,00092,831,744