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:30highload-churnerhighload-churnerScore: 10,020Success
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:506,32066,773,19317,147,00040,365,00092,844,032
2Oct 15, 2026 21:507,32175,745,83112,926,00053,700,00092,733,440
3Oct 15, 2026 21:507,49377,220,36112,978,00055,211,00092,725,248
4Oct 15, 2026 21:509,46395,187,42414,032,00072,090,00092,745,728
5Oct 15, 2026 21:5010,020100,240,37921,040,00070,148,00092,889,088
6Oct 15, 2026 21:5011,511126,996,25320,949,00083,803,00092,901,376
7Oct 15, 2026 21:5011,585114,483,85224,687,00080,745,00092,942,336
8Oct 15, 2026 21:5011,632114,926,64627,222,00078,630,00092,921,856
9Oct 15, 2026 21:5012,317121,417,43022,785,00089,303,00092,897,280