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:25Yuriy LyfenkoYuriy LyfenkoScore: 9,018Success
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:258,568142,643,96277,965,291094,756,864
2May 26, 2021 04:258,600156,891,65778,255,690094,670,848
3May 26, 2021 04:258,621141,634,48478,449,761094,760,960
4May 26, 2021 04:258,984106,278,15036,890,00044,866,00094,789,632
5May 26, 2021 04:258,987106,831,04833,910,00047,873,00094,658,560
6May 26, 2021 04:259,010107,722,73034,996,00046,995,00094,625,792
7May 26, 2021 04:259,018109,134,29938,030,00044,034,00094,547,968
8May 26, 2021 04:259,025109,052,90734,053,00048,075,00094,695,424
9May 26, 2021 04:259,028108,661,14431,057,00051,094,00094,715,904
10May 26, 2021 04:259,063108,469,59234,195,00048,275,00094,638,080
11May 26, 2021 04:259,228105,079,88634,990,00048,986,00093,089,792
12May 26, 2021 04:259,389113,274,53136,186,00049,253,00093,188,096