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 23:18highload-churnerhighload-churnerScore: 6,269Success
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 23:242,35530,408,86813,001,0008,431,00091,742,208
2Oct 15, 2026 23:242,37330,578,75012,996,0008,601,00091,672,576
3Oct 15, 2026 23:245,08555,322,39623,693,00022,589,00091,873,280
4Oct 15, 2026 23:246,24765,813,91928,369,00028,482,00091,987,968
5Oct 15, 2026 23:246,26966,147,31727,386,00029,666,00091,938,816
6Oct 15, 2026 23:246,33666,693,51529,062,00028,603,00091,979,776
7Oct 15, 2026 23:246,52968,653,68629,154,00030,264,00091,947,008
8Oct 15, 2026 23:246,55268,684,38229,065,00030,559,00091,942,912
9Oct 15, 2026 23:246,61269,290,92429,101,00031,072,00091,938,816