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 22:12highload-churnerhighload-churnerScore: 4,592Success
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 22:172,35030,516,74312,890,0008,504,00091,795,456
2Oct 15, 2026 22:172,36130,607,97612,959,0008,535,00091,758,592
3Oct 15, 2026 22:172,36930,592,90512,932,0008,627,00091,742,208
4Oct 15, 2026 22:174,54950,446,66412,918,00028,481,00091,910,144
5Oct 15, 2026 22:174,59250,982,94712,835,00028,954,00091,942,912
6Oct 15, 2026 22:174,61451,100,22712,882,00029,112,00091,893,760
7Oct 15, 2026 22:174,71351,911,68912,824,00030,071,00091,947,008
8Oct 15, 2026 22:174,97854,280,34412,869,00032,435,00091,963,392
9Oct 15, 2026 22:175,01254,619,37812,879,00032,735,00091,967,488