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 00:24Yurkov AlekseyYurkov AlekseyError
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 00:2300000Died or killed
2May 28, 2021 00:246,437127,723,25858,580,123092,561,408
3May 28, 2021 00:246,446123,709,19258,657,476092,565,504
4May 28, 2021 00:246,446119,091,66058,661,299092,561,408
5May 28, 2021 00:2412,935144,607,31299,755,00017,956,00092,471,296
6May 28, 2021 00:2412,938147,179,66697,782,00019,955,00092,700,672
7May 28, 2021 00:2412,940146,633,32199,793,00017,962,00092,643,328
8May 28, 2021 00:2412,952144,972,74999,881,00017,978,00092,631,040
9May 28, 2021 00:2412,952140,101,184101,882,00015,981,00092,626,944
10May 28, 2021 00:2412,966143,380,753101,992,00015,998,00092,704,768
11May 28, 2021 00:2412,975140,144,030104,060,00014,008,00092,631,040
12May 28, 2021 00:2413,111143,027,478101,262,00018,046,00092,188,672
13May 28, 2021 00:2413,217143,421,573102,232,00018,041,00092,188,672