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 20:59highload-churnerhighload-churnerScore: 6,553Success
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 21:084,54350,416,77621,462,00019,882,00092,827,648
2Oct 15, 2026 21:085,42558,475,94924,477,00024,894,00092,897,280
3Oct 15, 2026 21:086,39067,168,57528,383,00029,768,00092,934,144
4Oct 15, 2026 21:086,51268,303,55029,292,00029,972,00092,995,584
5Oct 15, 2026 21:086,55368,742,16429,236,00030,405,00092,999,680
6Oct 15, 2026 21:086,58068,948,69329,094,00030,790,00092,938,240
7Oct 15, 2026 21:086,61069,181,25329,311,00030,844,00093,003,776
8Oct 15, 2026 21:086,65269,666,32029,550,00030,988,00092,975,104
9Oct 15, 2026 21:086,65569,570,22129,275,00031,290,00092,954,624