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 13:28highload-churnerhighload-churnerScore: 2,656Success
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 13:342,64433,074,81915,758,0008,309,00092,741,632
2Oct 15, 2026 13:342,64733,146,98215,746,0008,347,00092,782,592
3Oct 15, 2026 13:342,64834,551,78415,734,0008,370,00092,733,440
4Oct 15, 2026 13:342,65133,099,95615,792,0008,336,00092,737,536
5Oct 15, 2026 13:342,65633,200,70315,822,0008,356,00092,758,016
6Oct 15, 2026 13:342,66333,294,68415,780,0008,462,00092,753,920
7Oct 15, 2026 13:342,66533,306,51715,816,0008,441,00092,729,344
8Oct 15, 2026 13:342,66533,260,25915,832,0008,422,00092,712,960
9Oct 15, 2026 13:342,66533,282,93915,730,0008,528,00092,749,824