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 21:23highload-churnerhighload-churnerScore: 6,597Success
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 21:362,36430,615,09413,041,0008,480,00092,721,152
2Oct 15, 2026 21:366,18165,337,68127,598,00028,658,00092,995,584
3Oct 15, 2026 21:366,38367,119,37629,085,00029,006,00092,950,528
4Oct 15, 2026 21:366,40067,335,89929,166,00029,080,00092,946,432
5Oct 15, 2026 21:366,59769,040,23829,148,00030,888,00092,995,584
6Oct 15, 2026 21:366,61569,217,28529,465,00030,737,00092,946,432
7Oct 15, 2026 21:367,68779,018,59729,265,00040,687,00092,987,392
8Oct 15, 2026 21:367,86280,925,91429,229,00042,318,00095,076,352
9Oct 15, 2026 21:367,93081,258,87829,368,00042,798,00092,958,720