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 06:18highload-churnerhighload-churnerScore: 4,631Success
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 06:244,61850,952,94733,756,0008,268,00092,696,576
2Oct 15, 2026 06:244,62050,982,06833,773,0008,270,00092,725,248
3Oct 15, 2026 06:244,62751,014,60433,760,0008,347,00092,774,400
4Oct 15, 2026 06:244,62951,063,20533,812,0008,314,00092,712,960
5Oct 15, 2026 06:244,63151,106,79033,773,0008,370,00092,700,672
6Oct 15, 2026 06:244,63351,129,04233,803,0008,363,00092,749,824
7Oct 15, 2026 06:244,63751,805,61533,693,0008,509,00092,745,728
8Oct 15, 2026 06:244,64251,194,50234,032,0008,215,00092,741,632
9Oct 15, 2026 06:244,67751,484,70034,205,0008,361,00092,741,632