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 10:07highload-churnerhighload-churnerScore: 2,794Success
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 10:132,78834,325,40816,855,0008,523,00092,721,152
2Oct 15, 2026 10:132,79034,333,77016,863,0008,535,00092,753,920
3Oct 15, 2026 10:132,79334,427,27816,851,0008,572,00092,729,344
4Oct 15, 2026 10:132,79434,386,24616,904,0008,524,00092,782,592
5Oct 15, 2026 10:132,79434,439,05916,860,0008,571,00092,774,400
6Oct 15, 2026 10:132,80234,482,88416,868,0008,639,00092,749,824
7Oct 15, 2026 10:132,80534,471,99816,859,0008,673,00092,749,824
8Oct 15, 2026 10:132,80834,602,41216,895,0008,663,00092,717,056
9Oct 15, 2026 10:134,17847,045,14229,611,0008,411,00092,762,112