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 15, 2026 10:45highload-churnerhighload-churnerScore: 2,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 15, 2026 10:512,72033,769,29916,184,0008,577,00092,749,824
2Oct 15, 2026 10:512,72333,778,74916,212,0008,576,00092,725,248
3Oct 15, 2026 10:512,72333,841,49716,214,0008,568,00092,676,096
4Oct 15, 2026 10:512,72333,808,25916,239,0008,541,00092,700,672
5Oct 15, 2026 10:512,73133,917,39816,204,0008,656,00092,700,672
6Oct 15, 2026 10:512,73133,916,43116,223,0008,638,00092,753,920
7Oct 15, 2026 10:512,73133,869,38916,190,0008,671,00092,667,904
8Oct 15, 2026 10:512,73333,889,79016,172,0008,706,00092,753,920
9Oct 15, 2026 10:512,74934,012,08916,264,0008,752,00092,684,288