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:51Yurkov AlekseyYurkov AlekseyScore: 6,494Success
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:516,334120,352,07857,635,950092,549,120
2May 27, 2021 12:516,357113,925,34857,847,177092,573,696
3May 27, 2021 12:516,376123,558,69758,024,210092,561,408
4May 27, 2021 12:516,44884,188,63540,776,00017,901,00092,704,768
5May 27, 2021 12:516,45781,617,56142,549,00016,209,00092,471,296
6May 27, 2021 12:516,48086,577,20442,979,00015,992,00092,708,864
7May 27, 2021 12:516,49481,496,47942,065,00017,026,00092,454,912
8May 27, 2021 12:516,49881,189,55542,091,00017,037,00092,700,672
9May 27, 2021 12:516,50880,749,54841,157,00018,068,00092,471,296
10May 27, 2021 12:516,51188,220,06843,185,00016,068,00092,471,296
11May 27, 2021 12:516,56183,386,50942,786,00016,915,00092,188,672
12May 27, 2021 12:517,01592,616,53441,893,00021,944,00092,209,152