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 listAug 16, 2026 23:10Tomislav TunkovicTomislav TunkovicScore: 7,254Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 17, 2026 04:056,46466,975,57250,411,0008,417,00092,774,400
2Aug 17, 2026 04:057,08372,409,97450,460,00014,001,00092,766,208
3Aug 17, 2026 04:057,12772,992,28850,774,00014,084,00092,803,072
4Aug 17, 2026 04:057,18573,507,76951,596,00013,796,00092,684,288
5Aug 17, 2026 04:057,25474,185,82852,165,00013,848,00092,749,824
6Aug 17, 2026 04:057,26074,305,83352,128,00013,940,00092,725,248
7Aug 17, 2026 04:057,26174,176,64852,199,00013,881,00092,758,016
8Aug 17, 2026 04:057,27174,266,15752,164,00014,007,00092,733,440
9Aug 17, 2026 04:057,27174,279,98852,221,00013,951,00092,766,208