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 09:11highload-churnerhighload-churnerScore: 3,179Success
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 09:173,14837,751,93019,250,0009,401,00092,729,344
2Oct 15, 2026 09:173,15437,748,70619,267,0009,439,00092,827,648
3Oct 15, 2026 09:173,15737,679,42719,312,0009,422,00092,704,768
4Oct 15, 2026 09:173,15837,854,41419,228,0009,514,00092,745,728
5Oct 15, 2026 09:173,17937,960,60119,362,0009,567,00092,696,576
6Oct 15, 2026 09:173,17937,938,45419,366,0009,570,00092,778,496
7Oct 15, 2026 09:173,18038,019,56619,308,0009,636,00092,803,072
8Oct 15, 2026 09:173,18537,916,17019,380,0009,610,00092,766,208
9Oct 15, 2026 09:173,18938,075,78719,465,0009,561,00092,692,480