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 18:41Yuriy LyfenkoYuriy LyfenkoScore: 9,901Success
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 18:414,806108,890,37043,733,581094,654,464
2May 26, 2021 18:414,856105,916,36144,190,679094,658,560
3May 26, 2021 18:415,255112,183,61347,824,823094,654,464
4May 26, 2021 18:419,881113,148,86574,933,00014,986,00094,679,040
5May 26, 2021 18:419,890118,211,08172,002,00018,000,00094,552,064
6May 26, 2021 18:419,895111,313,75675,035,00015,007,00094,785,536
7May 26, 2021 18:419,901111,700,10971,077,00019,020,00094,687,232
8May 26, 2021 18:419,942115,031,03876,396,00014,072,00094,674,944
9May 26, 2021 18:419,948114,985,10775,439,00015,087,00094,683,136
10May 26, 2021 18:419,965122,108,89675,732,00014,947,00092,983,296
11May 26, 2021 18:4110,019113,975,90177,149,00014,027,00092,979,200
12May 26, 2021 18:4110,076120,954,83079,732,00011,959,00093,106,176