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 05:11highload-churnerhighload-churnerScore: 2,323Success
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 05:172,30430,257,19513,380,0007,589,00091,770,880
2Nov 8, 2026 05:172,30930,353,17413,420,0007,593,00091,783,168
3Nov 8, 2026 05:172,31030,317,86013,405,0007,620,00091,738,112
4Nov 8, 2026 05:172,31330,356,50413,462,0007,591,00091,701,248
5Nov 8, 2026 05:172,32330,407,15513,433,0007,714,00091,774,976
6Nov 8, 2026 05:172,32532,212,54412,852,0008,314,00091,750,400
7Nov 8, 2026 05:172,32730,546,25013,468,0007,713,00091,717,632
8Nov 8, 2026 05:172,32930,458,57312,776,0008,424,00091,697,152
9Nov 8, 2026 05:172,33030,499,68812,853,0008,351,00091,766,784