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 9, 2026 15:12highload-churnerhighload-churnerError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Oct 13, 2026 12:19Andrew Epstein80.36CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Oct 13, 2026 12:340614,274,576581,797,00022,822,000132,145,152invalid character '1' after object key:value pair
2Oct 13, 2026 12:340612,654,854580,901,00022,677,000134,242,304invalid character '1' after object key:value pair
3Oct 13, 2026 12:340613,547,543581,303,00022,913,000134,242,304invalid character '1' after object key:value pair
4Oct 9, 2026 15:3212,412122,275,19097,124,00015,829,00094,392,320
5Oct 9, 2026 15:3212,444122,263,64096,870,00016,371,00094,392,320
6Oct 9, 2026 15:3212,483122,691,57497,445,00016,151,00094,392,320