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:52highload-churnerhighload-churnerScore: 2,537Success
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:582,53432,104,70014,743,0008,319,00092,729,344
2Oct 15, 2026 15:582,53532,134,72314,796,0008,274,00092,745,728
3Oct 15, 2026 15:582,53632,145,06414,814,0008,267,00092,753,920
4Oct 15, 2026 15:582,53732,192,91814,792,0008,297,00092,717,056
5Oct 15, 2026 15:582,53732,142,92314,798,0008,296,00092,733,440
6Oct 15, 2026 15:582,54832,364,52314,583,0008,608,00092,782,592
7Oct 15, 2026 15:582,55732,379,32814,816,0008,461,00092,811,264
8Oct 15, 2026 15:582,55832,322,73614,856,0008,430,00092,721,152
9Oct 15, 2026 15:582,57332,526,97614,829,0008,587,00092,725,248