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 16, 2026 01:42highload-churnerhighload-churnerScore: 6,815Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Oct 16, 2026 01:485,36958,596,21520,913,00027,951,00092,844,032
2Oct 16, 2026 01:485,45158,720,21920,813,00028,798,00092,868,608
3Oct 16, 2026 01:486,56168,783,19120,224,00039,488,00092,786,688
4Oct 16, 2026 01:486,80370,913,43529,183,00032,731,00092,913,664
5Oct 16, 2026 01:486,81571,175,82529,186,00032,831,00092,934,144
6Oct 16, 2026 01:486,84171,312,90329,183,00033,071,00092,983,296
7Oct 16, 2026 01:487,01172,940,46429,218,00034,591,00093,003,776
8Oct 16, 2026 01:487,04973,142,29829,384,00034,767,00092,979,200
9Oct 16, 2026 01:487,27175,689,19029,557,00036,611,00092,979,200