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 21:11highload-churnerhighload-churnerScore: 6,760Success
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:236,03963,939,15826,433,00028,527,00092,938,240stderr
2Oct 15, 2026 21:236,52468,428,65728,254,00031,123,00093,007,872stderr
3Oct 15, 2026 21:236,61569,236,21929,322,00030,875,00092,962,816stderr
4Oct 15, 2026 21:236,73770,505,09829,398,00031,913,00092,966,912stderr
5Oct 15, 2026 21:236,76070,562,88929,315,00032,204,00092,991,488stderr
6Oct 15, 2026 21:236,76870,572,06629,379,00032,212,00092,983,296stderr
7Oct 15, 2026 21:236,80871,031,01429,314,00032,646,00092,942,336stderr
8Oct 15, 2026 21:236,90771,875,65229,392,00033,463,00092,950,528stderr
9Oct 15, 2026 21:237,05973,347,00129,509,00034,734,00092,930,048stderr