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 09:38highload-churnerhighload-churnerScore: 2,844Success
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 09:442,83336,114,95917,265,0008,521,00092,717,056
2Oct 15, 2026 09:442,83634,819,31617,279,0008,537,00092,741,632
3Oct 15, 2026 09:442,83634,816,82317,279,0008,532,00092,774,400
4Oct 15, 2026 09:442,84034,826,00117,296,0008,555,00092,766,208
5Oct 15, 2026 09:442,84434,940,89917,305,0008,584,00092,725,248
6Oct 15, 2026 09:442,84434,920,46417,265,0008,622,00092,811,264
7Oct 15, 2026 09:442,84434,905,83517,302,0008,580,00092,758,016
8Oct 15, 2026 09:442,86035,023,05717,321,0008,706,00092,729,344
9Oct 15, 2026 09:442,86235,011,96717,343,0008,705,00092,733,440