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 17:18highload-churnerhighload-churnerScore: 2,504Success
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 17:242,48531,754,68114,297,0008,322,00092,737,536
2Oct 15, 2026 17:242,48931,691,06014,331,0008,319,00092,803,072
3Oct 15, 2026 17:242,49431,923,31114,370,0008,328,00092,704,768
4Oct 15, 2026 17:242,50131,773,46814,352,0008,416,00092,737,536
5Oct 15, 2026 17:242,50431,826,07614,412,0008,379,00092,725,248
6Oct 15, 2026 17:242,50531,781,90114,366,0008,437,00092,729,344
7Oct 15, 2026 17:242,50731,857,73414,432,0008,384,00092,729,344
8Oct 15, 2026 17:242,50831,948,57814,394,0008,434,00092,766,208
9Oct 15, 2026 17:242,51331,937,99714,427,0008,443,00092,790,784