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 19:22highload-churnerhighload-churnerScore: 2,509Success
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 19:302,49131,715,70014,319,0008,352,00092,798,976
2Oct 15, 2026 19:302,49731,753,52014,327,0008,400,00092,737,536
3Oct 15, 2026 19:302,50431,794,69814,334,0008,458,00092,753,920
4Oct 15, 2026 19:302,50631,846,37814,419,0008,391,00092,717,056
5Oct 15, 2026 19:302,50931,901,69614,382,0008,455,00092,766,208
6Oct 15, 2026 19:302,51032,164,67614,432,0008,414,00092,774,400
7Oct 15, 2026 19:302,51432,028,45514,386,0008,493,00092,737,536
8Oct 15, 2026 19:302,52232,032,60214,530,0008,426,00092,729,344
9Oct 15, 2026 19:302,52632,053,71414,427,0008,562,00092,741,632