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 16, 2026 03:11highload-churnerhighload-churnerScore: 2,507Success
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Oct 16, 2026 03:182,49731,799,13513,036,0009,690,00092,762,112stderr
2Oct 16, 2026 03:182,50131,756,76113,028,0009,737,00092,749,824stderr
3Oct 16, 2026 03:182,50331,745,07812,981,0009,798,00092,708,864stderr
4Oct 16, 2026 03:182,50431,893,91412,987,0009,808,00092,794,880stderr
5Oct 16, 2026 03:182,50731,776,07513,122,0009,695,00092,729,344stderr
6Oct 16, 2026 03:182,50731,766,44913,021,0009,799,00092,770,304stderr
7Oct 16, 2026 03:182,50931,839,94113,070,0009,768,00092,749,824stderr
8Oct 16, 2026 03:182,51031,834,96713,099,0009,743,00092,667,904stderr
9Oct 16, 2026 03:182,53131,990,86613,223,0009,812,00092,733,440stderr