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 listMay 28, 2021 01:03Yurkov AlekseyYurkov AlekseyScore: 13,336Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 28, 2021 01:036,377114,690,38258,031,104092,680,192
2May 28, 2021 01:036,410122,828,45358,327,523092,561,408
3May 28, 2021 01:036,411110,816,18358,342,823092,565,504
4May 28, 2021 01:0313,306142,208,663100,069,00021,014,00092,704,768
5May 28, 2021 01:0313,312147,397,03899,112,00022,025,00092,684,288
6May 28, 2021 01:0313,327140,621,978101,228,00020,045,00092,540,928
7May 28, 2021 01:0313,336152,289,867101,301,00020,059,00092,508,160
8May 28, 2021 01:0313,336145,654,80199,476,00021,884,00092,618,752
9May 28, 2021 01:0313,364149,866,21898,688,00022,927,00092,700,672
10May 28, 2021 01:0313,390150,187,33996,881,00024,969,00092,168,192
11May 28, 2021 01:0313,495146,790,68698,839,00023,961,00092,176,384
12May 28, 2021 01:0313,610151,484,40499,083,00024,770,00092,700,672