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 27, 2021 12:43Yurkov AlekseyYurkov AlekseyScore: 13,749Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 27, 2021 12:409,586160,413,41087,234,301092,561,408
2May 27, 2021 12:439,598154,665,00087,341,262092,565,504
3May 27, 2021 12:409,622147,116,27787,559,310092,565,504
4May 27, 2021 12:439,640161,646,58387,726,150092,549,120
5May 27, 2021 12:439,690153,700,11788,175,799092,692,480
6May 27, 2021 12:409,781147,860,80189,004,165092,569,600
7May 27, 2021 12:4313,730150,116,278107,950,00016,992,00092,463,104
8May 27, 2021 12:4013,737151,783,650107,005,00018,000,00092,700,672
9May 27, 2021 12:4313,738150,338,931110,011,00015,001,00092,631,040
10May 27, 2021 12:4013,740153,850,291111,028,00014,003,00092,585,984
11May 27, 2021 12:4013,744150,688,408107,059,00018,009,00092,463,104
12May 27, 2021 12:4313,745153,088,691109,073,00016,010,00092,463,104
13May 27, 2021 12:4013,749148,265,257109,103,00016,015,00092,569,600
14May 27, 2021 12:4313,768150,847,258110,254,00015,034,00092,463,104
15May 27, 2021 12:4013,771147,664,050109,279,00016,041,00092,471,296
16May 27, 2021 12:4313,785154,620,118109,387,00016,056,00092,700,672
17May 27, 2021 12:4313,786159,726,051109,396,00016,058,00092,700,672
18May 27, 2021 12:4013,790159,955,174108,424,00017,066,00092,545,024
19May 27, 2021 12:4313,842159,698,328110,969,00014,995,00092,184,576
20May 27, 2021 12:4314,001150,627,443105,339,00022,071,00092,168,192
21May 27, 2021 12:4014,028152,581,741109,706,00017,951,00092,184,576
22May 27, 2021 12:4014,061149,483,360108,959,00018,992,00092,340,224
23May 27, 2021 12:4314,107151,776,934106,313,00022,065,00092,188,672
24May 27, 2021 12:4014,148154,368,927106,789,00021,956,00092,180,480