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 17:41highload-churnerhighload-churnerScore: 3,494Success
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 17:483,46140,572,42414,625,00016,877,00094,392,320
2Oct 15, 2026 17:483,46540,603,87714,499,00017,035,00094,392,320
3Oct 15, 2026 17:483,47440,707,54214,622,00016,999,00094,392,320
4Oct 15, 2026 17:483,47540,726,75614,666,00016,959,00094,392,320
5Oct 15, 2026 17:483,49440,874,19714,570,00017,228,00094,392,320
6Oct 15, 2026 17:483,50140,979,34414,236,00017,630,00094,392,320
7Oct 15, 2026 17:483,51140,986,78914,701,00017,250,00094,392,320
8Oct 15, 2026 17:483,52141,138,01114,349,00017,701,00094,392,320
9Oct 15, 2026 17:483,55350,814,97914,524,00017,813,00094,392,320