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 listNov 8, 2026 05:21highload-churnerhighload-churnerScore: 2,305Success
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 8, 2026 05:272,29230,111,50313,254,0007,612,00091,738,112
2Nov 8, 2026 05:272,29530,201,19913,314,0007,575,00091,791,360
3Nov 8, 2026 05:272,29830,238,05913,285,0007,629,00091,713,536
4Nov 8, 2026 05:272,30231,514,91913,377,0007,573,00091,725,824
5Nov 8, 2026 05:272,30530,348,70813,267,0007,709,00091,766,784
6Nov 8, 2026 05:272,30530,304,85813,264,0007,715,00091,791,360
7Nov 8, 2026 05:272,31130,476,11713,417,0007,615,00091,750,400
8Nov 8, 2026 05:272,31830,363,18612,735,0008,361,00091,717,632
9Nov 8, 2026 05:272,32230,496,09013,442,0007,695,00091,742,208