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 13:13Yurkov AlekseyYurkov AlekseyScore: 6,480Success
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 13:136,327130,941,19457,576,508092,557,312
2May 27, 2021 13:136,331120,819,08057,609,424092,569,600
3May 27, 2021 13:136,347120,465,03957,760,226092,553,216
4May 27, 2021 13:136,46583,079,13942,881,00015,955,00092,688,384
5May 27, 2021 13:136,47682,822,27740,954,00017,979,00092,471,296
6May 27, 2021 13:136,47883,944,90441,962,00016,984,00092,475,392
7May 27, 2021 13:136,48083,076,12342,976,00015,991,00092,676,096
8May 27, 2021 13:136,48787,461,46441,021,00018,009,00092,700,672
9May 27, 2021 13:136,49983,000,26043,102,00016,037,00091,942,912
10May 27, 2021 13:136,49980,612,65742,099,00017,040,00091,926,528
11May 27, 2021 13:136,50783,875,66744,161,00015,055,00092,463,104
12May 27, 2021 13:136,51486,105,98944,205,00015,070,00092,700,672