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 17, 2026 12:39highload-churnerhighload-churnerScore: 2,314Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Oct 17, 2026 12:452,30430,308,55512,619,0008,355,00091,787,264
2Oct 17, 2026 12:452,30530,425,68612,701,0008,281,00091,758,592
3Oct 17, 2026 12:452,30730,389,38612,670,0008,325,00091,774,976
4Oct 17, 2026 12:452,31030,457,80412,583,0008,439,00091,807,744
5Oct 17, 2026 12:452,31430,510,76312,708,0008,357,00091,791,360
6Oct 17, 2026 12:452,31730,506,65812,692,0008,396,00091,774,976
7Oct 17, 2026 12:452,32130,457,97012,638,0008,485,00091,734,016
8Oct 17, 2026 12:452,32130,453,03912,749,0008,380,00091,754,496
9Oct 17, 2026 12:452,32930,509,17312,717,0008,480,00091,729,920