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 15:37highload-churnerhighload-churnerScore: 2,573Success
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 15:432,56332,426,02215,021,0008,306,00092,794,880
2Oct 15, 2026 15:432,56432,441,58515,035,0008,303,00092,766,208
3Oct 15, 2026 15:432,56732,429,41514,915,0008,449,00092,766,208
4Oct 15, 2026 15:432,57132,432,63115,055,0008,346,00092,749,824
5Oct 15, 2026 15:432,57332,411,40915,066,0008,356,00092,782,592
6Oct 15, 2026 15:432,57732,524,75415,073,0008,380,00092,741,632
7Oct 15, 2026 15:432,57832,472,57615,059,0008,406,00092,733,440
8Oct 15, 2026 15:432,59032,608,14715,135,0008,434,00092,815,360
9Oct 15, 2026 15:432,59932,637,06415,067,0008,589,00092,672,000