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 26, 2021 19:08Yurkov AlekseyYurkov AlekseyScore: 8,872Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 26, 2021 19:088,644105,622,37054,766,00023,897,00092,471,296
2May 26, 2021 19:088,650110,889,22359,781,00018,930,00092,471,296
3May 26, 2021 19:088,656109,327,05063,812,00014,955,00092,463,104
4May 26, 2021 19:088,673104,659,92960,940,00017,982,00092,471,296
5May 26, 2021 19:088,676102,149,67163,965,00014,991,00092,704,768
6May 26, 2021 19:088,701103,069,51264,145,00015,034,00092,463,104
7May 26, 2021 19:088,872109,642,81858,810,00021,929,00092,205,056
8May 26, 2021 19:088,975108,623,06859,757,00021,911,00092,209,152
9May 26, 2021 19:089,059109,504,90662,332,00020,107,00092,209,152
10May 26, 2021 19:0810,351150,620,30194,190,726092,557,312
11May 26, 2021 19:0810,376162,249,19894,424,006092,553,216
12May 26, 2021 19:0810,412161,746,26594,746,697092,573,696