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 19:01Yuriy LyfenkoYuriy LyfenkoScore: 9,769Success
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 19:014,793106,253,01143,614,397094,654,464
2May 26, 2021 19:014,812117,946,79443,789,950094,658,560
3May 26, 2021 19:014,949113,579,81045,036,379094,662,656
4May 26, 2021 19:019,738112,908,87273,683,00014,935,00094,547,968
5May 26, 2021 19:019,739119,737,75372,694,00015,933,00094,683,136
6May 26, 2021 19:019,751112,830,10874,619,00014,117,00094,679,040
7May 26, 2021 19:019,769111,917,59871,915,00016,979,00094,547,968
8May 26, 2021 19:019,790110,085,22473,071,00016,015,00094,543,872
9May 26, 2021 19:019,808111,291,78371,199,00018,050,00094,547,968
10May 26, 2021 19:019,839118,981,07378,469,00011,066,00093,106,176
11May 26, 2021 19:019,936118,080,22780,370,00010,046,00093,241,344
12May 26, 2021 19:0110,091117,726,08070,864,00020,960,00093,241,344