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:51highload-churnerhighload-churnerScore: 12,731Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Oct 9, 2026 16:1612,668124,334,37998,904,00016,383,00094,392,320
2Oct 9, 2026 16:1612,694124,549,53099,037,00016,479,00094,392,320
3Oct 9, 2026 16:1612,714125,102,85898,819,00016,884,00094,392,320
4Oct 9, 2026 16:1612,715125,646,30298,992,00016,719,00094,392,320
5Oct 9, 2026 16:1612,731126,170,35599,282,00016,573,00094,392,320
6Oct 9, 2026 16:1612,735126,316,89799,121,00016,773,00094,392,320
7Oct 9, 2026 16:1612,740124,996,20399,476,00016,459,00094,392,320
8Oct 9, 2026 16:1612,742124,929,95199,022,00016,933,00094,392,320
9Oct 9, 2026 16:1612,779125,285,26699,302,00016,988,00094,392,320