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 20:32highload-churnerhighload-churnerScore: 6,472Success
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 20:392,36530,759,12913,051,0008,473,00092,749,824
2Oct 15, 2026 20:392,36630,725,69513,066,0008,467,00092,729,344
3Oct 15, 2026 20:392,37830,699,07913,080,0008,568,00092,737,536
4Oct 15, 2026 20:392,38130,691,31713,063,0008,613,00092,786,688
5Oct 15, 2026 20:396,47268,023,71329,236,00029,664,00092,921,856
6Oct 15, 2026 20:396,52468,450,68629,309,00030,063,00092,942,336
7Oct 15, 2026 20:396,62469,789,14429,342,00030,942,00092,872,704
8Oct 15, 2026 20:396,69170,027,95228,414,00032,482,00092,954,624
9Oct 15, 2026 20:396,89471,840,71329,373,00033,365,00092,991,488