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 04:58highload-churnerhighload-churnerScore: 2,316Success
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:042,30230,334,94612,654,0008,298,00091,774,976
2Nov 8, 2026 05:042,30330,314,76012,640,0008,319,00091,803,648
3Nov 8, 2026 05:042,31330,341,53812,683,0008,374,00091,750,400
4Nov 8, 2026 05:042,31530,297,84312,726,0008,346,00091,820,032
5Nov 8, 2026 05:042,31630,521,38912,679,0008,404,00091,725,824
6Nov 8, 2026 05:042,31930,401,40712,733,0008,373,00091,750,400
7Nov 8, 2026 05:042,32530,420,95912,864,0008,301,00091,742,208
8Nov 8, 2026 05:042,32730,494,16812,727,0008,449,00091,762,688
9Nov 8, 2026 05:042,34930,749,86612,921,0008,459,00091,725,824