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 16, 2026 03:54highload-churnerhighload-churnerScore: 2,340Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Oct 16, 2026 04:002,33230,276,60412,912,0008,315,00091,779,072
2Oct 16, 2026 04:002,33430,236,38712,894,0008,351,00091,750,400
3Oct 16, 2026 04:002,33530,272,46212,943,0008,306,00091,770,880
4Oct 16, 2026 04:002,34030,286,92612,945,0008,354,00091,664,384
5Oct 16, 2026 04:002,34030,301,77312,975,0008,319,00091,783,168
6Oct 16, 2026 04:002,34330,317,50612,992,0008,334,00091,697,152
7Oct 16, 2026 04:002,34930,405,73812,929,0008,451,00091,770,880
8Oct 16, 2026 04:002,35730,480,25612,999,0008,452,00091,738,112
9Oct 16, 2026 04:002,37230,576,78513,070,0008,517,00091,791,360