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:22Yuriy LyfenkoYuriy LyfenkoScore: 9,663Success
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:224,776124,061,00443,466,147094,662,656
2May 26, 2021 19:224,787116,039,48943,558,215094,654,464
3May 26, 2021 19:224,902116,462,80744,605,777094,658,560
4May 26, 2021 19:229,617113,327,12270,610,00016,906,00094,683,136
5May 26, 2021 19:229,635111,615,99570,737,00016,937,00094,552,064
6May 26, 2021 19:229,641110,616,03269,785,00017,944,00094,547,968
7May 26, 2021 19:229,663113,187,92873,942,00013,989,00094,552,064
8May 26, 2021 19:229,664119,750,14870,956,00016,989,00094,674,944
9May 26, 2021 19:229,700108,545,79075,228,00013,039,00094,777,344
10May 26, 2021 19:229,862112,820,59470,800,00018,946,00093,114,368
11May 26, 2021 19:229,872115,065,02570,872,00018,965,00093,106,176
12May 26, 2021 19:229,984114,801,50768,890,00021,965,00093,245,440