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 23:33highload-churnerhighload-churnerScore: 5,351Success
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 23:395,11555,549,52916,133,00030,420,00091,979,776
2Oct 15, 2026 23:395,27657,072,24316,049,00031,964,00091,967,488
3Oct 15, 2026 23:395,29457,269,82816,148,00032,036,00091,947,008
4Oct 15, 2026 23:395,32657,527,18916,093,00032,380,00091,951,104
5Oct 15, 2026 23:395,35157,753,79916,317,00032,378,00091,955,200
6Oct 15, 2026 23:395,35957,858,22916,076,00032,696,00091,881,472
7Oct 15, 2026 23:395,36057,817,84116,334,00032,449,00091,951,104
8Oct 15, 2026 23:395,41358,350,09316,144,00033,115,00091,955,200
9Oct 15, 2026 23:395,48759,119,15016,116,00033,817,00091,942,912