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 13, 2026 13:50highload-churnerhighload-churnerScore: 15,481Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Oct 13, 2026 13:5615,464149,713,086132,399,0008,330,00092,753,920
2Oct 13, 2026 13:5615,479150,395,556132,423,0008,440,00092,778,496
3Oct 13, 2026 13:5615,479150,420,795132,462,0008,404,00092,741,632
4Oct 13, 2026 13:5615,480149,776,431132,411,0008,461,00092,782,592
5Oct 13, 2026 13:5615,481149,855,439132,397,0008,481,00092,676,096
6Oct 13, 2026 13:5615,484150,506,757132,502,0008,405,00092,778,496
7Oct 13, 2026 13:5615,484149,874,313132,459,0008,446,00092,758,016
8Oct 13, 2026 13:5615,490150,348,293132,502,0008,457,00092,692,480
9Oct 13, 2026 13:5615,493150,634,799132,465,0008,522,00092,700,672