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:15highload-churnerhighload-churnerScore: 2,374Success
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:202,36430,626,87913,039,0008,480,00092,721,152
2Oct 15, 2026 20:202,36530,692,50213,078,0008,450,00092,680,192
3Oct 15, 2026 20:202,36530,596,67413,082,0008,445,00092,729,344
4Oct 15, 2026 20:202,37330,690,04813,125,0008,470,00092,733,440
5Oct 15, 2026 20:202,37431,428,31213,124,0008,483,00092,790,784
6Oct 15, 2026 20:202,38432,121,03813,113,0008,587,00092,692,480
7Oct 15, 2026 20:202,38530,835,49313,107,0008,602,00092,766,208
8Oct 15, 2026 20:202,39230,838,28713,185,0008,585,00092,758,016
9Oct 15, 2026 20:202,39830,887,02713,193,0008,630,00092,835,840