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:08Andrew Epstein10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Oct 13, 2026 12:180610,604,927578,657,00022,931,000134,242,304invalid character '1' after object key:value pair
2Oct 13, 2026 12:180610,891,694578,079,00023,707,000132,145,152invalid character '1' after object key:value pair
3Oct 13, 2026 12:180611,248,750578,487,00023,100,000132,145,152invalid character '1' after object key:value pair
4Oct 9, 2026 15:4412,325121,321,59995,655,00016,507,00094,392,320
5Oct 9, 2026 15:4412,329121,684,35895,477,00016,719,00094,392,320
6Oct 9, 2026 15:4412,336121,326,55895,488,00016,776,00094,392,320
7Oct 9, 2026 15:4412,343121,361,70695,477,00016,852,00094,392,320
8Oct 9, 2026 15:4412,353121,391,66195,578,00016,841,00094,392,320
9Oct 9, 2026 15:4412,354131,191,12195,702,00016,721,00094,392,320
10Oct 9, 2026 15:4412,401130,192,55795,977,00016,879,00094,392,320
11Oct 9, 2026 15:4412,423130,234,64496,278,00016,778,00094,392,320
12Oct 9, 2026 15:4412,446132,494,48595,647,00017,614,00094,392,320