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 11:16highload-churnerhighload-churnerScore: 2,741Success
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 11:222,73133,899,11416,307,0008,554,00092,774,400
2Oct 15, 2026 11:222,73233,896,40616,300,0008,564,00092,708,864
3Oct 15, 2026 11:222,73433,900,52916,286,0008,594,00092,753,920
4Oct 15, 2026 11:222,73533,872,33216,325,0008,567,00092,729,344
5Oct 15, 2026 11:222,74133,919,46816,333,0008,613,00092,790,784
6Oct 15, 2026 11:222,74134,015,21416,292,0008,658,00092,708,864
7Oct 15, 2026 11:222,74133,971,06416,353,0008,593,00092,688,384
8Oct 15, 2026 11:222,74233,956,77516,295,0008,666,00092,741,632
9Oct 15, 2026 11:222,75134,063,73516,330,0008,713,00092,737,536