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 04:39Yuriy LyfenkoYuriy LyfenkoScore: 14,230Success
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 04:398,517136,054,61477,506,380094,670,848
2May 26, 2021 04:398,547137,802,73177,782,186094,679,040
3May 26, 2021 04:398,562138,912,61177,918,439094,785,536
4May 26, 2021 04:3914,187157,981,91485,067,00044,035,00094,609,408
5May 26, 2021 04:3914,200152,211,59073,122,00056,094,00094,580,736
6May 26, 2021 04:3914,209154,517,56483,194,00046,107,00094,556,160
7May 26, 2021 04:3914,230159,702,47382,313,00047,179,00094,588,928
8May 26, 2021 04:3914,230162,415,24877,296,00052,200,00094,769,152
9May 26, 2021 04:3914,239166,830,25485,717,00043,855,00094,593,024
10May 26, 2021 04:3914,246154,375,16582,406,00047,232,00094,744,576
11May 26, 2021 04:3914,817158,671,49071,911,00062,922,00093,093,888
12May 26, 2021 04:3914,851156,100,16282,087,00053,056,00093,249,536