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 18:56highload-churnerhighload-churnerScore: 2,963Success
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 19:022,94635,829,18618,359,0008,450,00092,753,920
2Oct 15, 2026 19:022,95135,894,12118,353,0008,502,00092,729,344
3Oct 15, 2026 19:022,95535,919,48218,394,0008,501,00092,745,728
4Oct 15, 2026 19:022,95836,044,14018,463,0008,462,00092,717,056
5Oct 15, 2026 19:022,96336,001,43618,506,0008,462,00092,729,344
6Oct 15, 2026 19:022,96636,076,08018,518,0008,476,00092,688,384
7Oct 15, 2026 19:022,97736,125,65818,524,0008,570,00092,729,344
8Oct 15, 2026 19:022,97736,208,60918,471,0008,622,00092,774,400
9Oct 15, 2026 19:023,03436,667,92319,028,0008,587,00092,717,056