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 10:16highload-churnerhighload-churnerScore: 2,766Success
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 10:222,76134,160,10816,567,0008,562,00092,712,960
2Oct 15, 2026 10:222,76234,280,48216,566,0008,571,00092,758,016
3Oct 15, 2026 10:222,76434,196,67616,606,0008,553,00092,766,208
4Oct 15, 2026 10:222,76534,170,24916,589,0008,580,00092,798,976
5Oct 15, 2026 10:222,76634,208,75016,590,0008,585,00092,729,344
6Oct 15, 2026 10:222,77134,183,85516,607,0008,610,00092,803,072
7Oct 15, 2026 10:222,77234,217,53016,568,0008,666,00092,745,728
8Oct 15, 2026 10:222,77234,286,79016,579,0008,655,00092,729,344
9Oct 15, 2026 10:222,77334,268,74016,565,0008,678,00092,749,824