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 listNov 8, 2026 06:01highload-churnerhighload-churnerScore: 2,310Success
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 8, 2026 06:072,28930,118,29813,249,0007,581,00091,742,208
2Nov 8, 2026 06:072,29530,229,22413,307,0007,585,00091,783,168
3Nov 8, 2026 06:072,30130,341,65813,278,0007,669,00091,750,400
4Nov 8, 2026 06:072,30730,410,57912,709,0008,289,00091,758,592
5Nov 8, 2026 06:072,31030,387,71913,292,0007,729,00091,758,592
6Nov 8, 2026 06:072,31430,393,49013,419,0007,640,00091,762,688
7Nov 8, 2026 06:072,32430,455,91212,826,0008,326,00091,774,976
8Nov 8, 2026 06:072,32630,494,75412,874,0008,299,00091,750,400
9Nov 8, 2026 06:072,33330,638,52012,796,0008,443,00091,721,728