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 28, 2021 00:18Yurkov AlekseyYurkov AlekseyScore: 12,974Success
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 28, 2021 00:186,071121,319,01155,248,029092,565,504
2May 28, 2021 00:186,094120,614,91555,452,507092,553,216
3May 28, 2021 00:196,096160,670,14155,476,063092,557,312
4May 28, 2021 00:196,098109,615,85055,494,102092,557,312
5May 28, 2021 00:186,104114,721,31955,550,357092,565,504
6May 28, 2021 00:196,207115,183,07256,484,500092,549,120
7May 28, 2021 00:1812,955140,085,910100,903,00016,983,00092,704,768
8May 28, 2021 00:1912,957139,975,38398,922,00018,985,00092,680,192
9May 28, 2021 00:1912,958145,189,642101,926,00015,988,00092,700,672
10May 28, 2021 00:1912,964143,637,956101,974,00015,996,00092,663,808
11May 28, 2021 00:1912,972143,722,05898,038,00020,007,00092,659,712
12May 28, 2021 00:1812,973140,935,326103,047,00015,006,00092,463,104
13May 28, 2021 00:1812,974145,851,476101,051,00017,008,00092,635,136
14May 28, 2021 00:1912,981140,742,954101,107,00017,018,00092,700,672
15May 28, 2021 00:1912,982138,372,122102,119,00016,018,00092,585,984
16May 28, 2021 00:1812,984137,899,462100,131,00018,023,00092,569,600
17May 28, 2021 00:1812,988139,688,897101,160,00017,027,00092,602,368
18May 28, 2021 00:1813,004141,572,965101,286,00017,048,00092,700,672
19May 28, 2021 00:1813,028148,586,48498,633,00019,926,00092,602,368
20May 28, 2021 00:1913,069147,567,085104,933,00013,991,00092,209,152
21May 28, 2021 00:1813,076146,086,943101,997,00016,999,00092,192,768
22May 28, 2021 00:1813,084140,102,576102,052,00017,008,00091,942,912
23May 28, 2021 00:1913,145146,162,428103,535,00016,083,00092,196,864
24May 28, 2021 00:1913,313144,814,148101,123,00020,024,00092,143,616