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 20:46highload-churnerhighload-churnerScore: 2,378Success
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 20:532,37630,738,57513,186,0008,444,00092,717,056stderr
2Oct 15, 2026 20:532,37630,759,75313,179,0008,449,00092,778,496stderr
3Oct 15, 2026 20:532,37730,737,56813,136,0008,501,00092,774,400stderr
4Oct 15, 2026 20:532,37830,671,05013,161,0008,485,00092,770,304stderr
5Oct 15, 2026 20:532,37830,694,02613,143,0008,498,00092,717,056stderr
6Oct 15, 2026 20:532,39030,898,58713,129,0008,628,00092,762,112stderr
7Oct 15, 2026 20:532,39630,878,59613,111,0008,698,00092,712,960stderr
8Oct 15, 2026 20:532,41931,092,34213,235,0008,785,00092,737,536stderr
9Oct 15, 2026 20:532,42331,109,88013,390,0008,666,00092,737,536stderr