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 16:17highload-churnerhighload-churnerScore: 2,516Success
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 16:232,49831,777,12214,413,0008,327,00092,737,536
2Oct 15, 2026 16:232,50831,884,19914,451,0008,373,00092,762,112
3Oct 15, 2026 16:232,50931,880,98114,421,0008,412,00092,749,824
4Oct 15, 2026 16:232,51432,051,50714,447,0008,436,00092,766,208
5Oct 15, 2026 16:232,51632,041,96314,396,0008,500,00092,729,344
6Oct 15, 2026 16:232,52332,023,02414,578,0008,390,00092,745,728
7Oct 15, 2026 16:232,52832,117,14114,463,0008,549,00092,712,960
8Oct 15, 2026 16:232,53332,116,55814,581,0008,470,00092,737,536
9Oct 15, 2026 16:232,54732,826,72714,545,0008,634,00092,721,152