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:49highload-churnerhighload-churnerScore: 2,301Success
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:542,29430,189,52113,295,0007,588,00091,705,344
2Nov 8, 2026 05:542,29730,188,26513,316,0007,589,00091,693,056
3Nov 8, 2026 05:542,29830,290,11713,312,0007,607,00091,721,728
4Nov 8, 2026 05:542,29930,221,74513,291,0007,635,00091,766,784
5Nov 8, 2026 05:542,30130,201,19612,628,0008,313,00091,688,960
6Nov 8, 2026 05:542,30830,328,32713,285,0007,721,00091,709,440
7Nov 8, 2026 05:542,30930,363,66713,283,0007,733,00091,779,072
8Nov 8, 2026 05:542,31030,311,50413,399,0007,631,00091,705,344
9Nov 8, 2026 05:542,31430,333,42813,368,0007,694,00091,783,168