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 listOct 15, 2026 11:37highload-churnerhighload-churnerScore: 2,671Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Oct 15, 2026 11:422,65833,297,17715,892,0008,298,00092,758,016
2Oct 15, 2026 11:422,67033,255,86615,834,0008,466,00092,762,112
3Oct 15, 2026 11:422,67033,355,99015,881,0008,416,00092,827,648
4Oct 15, 2026 11:422,67033,321,65915,838,0008,468,00092,766,208
5Oct 15, 2026 11:422,67133,336,75815,849,0008,460,00092,794,880
6Oct 15, 2026 11:422,67433,369,57615,831,0008,504,00092,758,016
7Oct 15, 2026 11:422,67533,386,65215,888,0008,455,00092,721,152
8Oct 15, 2026 11:422,67633,391,83215,906,0008,447,00092,717,056
9Oct 15, 2026 11:422,67933,501,17715,966,0008,419,00092,733,440