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 27, 2021 12:44Yurkov AlekseyYurkov AlekseyScore: 8,345Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 27, 2021 12:448,208103,525,17156,767,00017,926,00092,450,816
2May 27, 2021 12:448,219105,315,06858,840,00015,956,00092,463,104
3May 27, 2021 12:448,22199,172,57957,851,00016,956,00092,471,296
4May 27, 2021 12:448,23098,020,50057,918,00016,976,00092,463,104
5May 27, 2021 12:448,24298,811,75358,003,00017,000,00092,450,816
6May 27, 2021 12:448,25798,415,22559,112,00016,030,00092,463,104
7May 27, 2021 12:448,34599,442,07257,956,00017,986,00092,192,768
8May 27, 2021 12:448,49896,403,48759,258,00018,078,00092,172,288
9May 27, 2021 12:448,606104,284,33059,242,00019,077,00092,033,024
10May 27, 2021 12:449,573154,606,55587,109,839092,561,408
11May 27, 2021 12:449,609148,791,84987,442,435092,549,120
12May 27, 2021 12:449,699155,167,13988,260,447092,553,216