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 14:46highload-churnerhighload-churnerScore: 2,599Success
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 14:522,58232,473,00315,204,0008,299,00092,712,960
2Oct 15, 2026 14:522,58232,500,73415,201,0008,304,00092,782,592
3Oct 15, 2026 14:522,58332,535,98815,211,0008,299,00092,782,592
4Oct 15, 2026 14:522,59632,621,71915,232,0008,392,00092,733,440
5Oct 15, 2026 14:522,59932,696,37515,294,0008,364,00092,721,152
6Oct 15, 2026 14:522,59932,791,58315,143,0008,516,00092,737,536
7Oct 15, 2026 14:522,60132,916,32115,215,0008,457,00092,733,440
8Oct 15, 2026 14:522,60232,733,01215,257,0008,424,00092,733,440
9Oct 15, 2026 14:522,62533,568,37815,271,0008,624,00092,729,344