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:01Yurkov AlekseyYurkov AlekseyScore: 12,936Success
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:016,249137,813,70656,861,642092,565,504
2May 28, 2021 01:016,272130,753,01757,076,024092,573,696
3May 28, 2021 01:016,419127,735,75358,409,834092,565,504
4May 28, 2021 01:0112,908143,527,834100,398,00017,067,00092,471,296
5May 28, 2021 01:0112,922138,797,84096,666,00020,927,00092,708,864
6May 28, 2021 01:0112,934140,633,35099,745,00017,954,00092,631,040
7May 28, 2021 01:0112,936144,202,206101,759,00015,962,00092,626,944
8May 28, 2021 01:0112,943145,273,65098,816,00018,964,00092,454,912
9May 28, 2021 01:0112,978143,436,594101,086,00017,014,00092,471,296
10May 28, 2021 01:0113,106144,059,867102,224,00017,037,00092,110,848
11May 28, 2021 01:0113,208150,611,011100,164,00020,032,00092,155,904
12May 28, 2021 01:0113,265147,054,273100,760,00019,952,00092,098,560