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:47Yuriy LyfenkoYuriy LyfenkoScore: 14,144Success
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:478,520141,060,33877,530,561094,679,040
2May 26, 2021 04:478,550149,242,81877,802,423094,760,960
3May 26, 2021 04:478,564130,871,04377,931,857094,748,672
4May 26, 2021 04:4714,138157,107,19182,777,00045,876,00094,769,152
5May 26, 2021 04:4714,139159,938,62484,781,00043,887,00094,576,640
6May 26, 2021 04:4714,142155,005,18879,810,00048,883,00094,564,352
7May 26, 2021 04:4714,144159,367,35485,808,00042,904,00094,769,152
8May 26, 2021 04:4714,184154,989,39384,051,00045,027,00094,547,968
9May 26, 2021 04:4714,225161,615,85483,286,00046,158,00094,588,928
10May 26, 2021 04:4714,256161,250,28684,823,00044,906,00094,547,968
11May 26, 2021 04:4714,377157,298,89979,897,00050,934,00092,991,488
12May 26, 2021 04:4714,446154,105,49578,276,00053,187,00093,048,832