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:11Yurkov AlekseyYurkov AlekseyScore: 14,855Success
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:1110,920165,056,33499,368,924092,672,000
2May 26, 2021 19:1110,923180,090,95899,395,894092,549,120
3May 26, 2021 19:1111,050163,679,580100,552,942092,545,024
4May 26, 2021 19:1114,833159,278,000108,981,00025,995,00092,459,008
5May 26, 2021 19:1114,838159,032,295116,025,00019,004,00092,459,008
6May 26, 2021 19:1114,850160,687,580113,115,00022,022,00092,459,008
7May 26, 2021 19:1114,855160,171,669118,286,00016,898,00092,692,480
8May 26, 2021 19:1114,859160,702,397118,189,00017,027,00092,459,008
9May 26, 2021 19:1114,868162,807,674115,253,00020,044,00092,528,640
10May 26, 2021 19:1115,198160,009,159122,267,00016,035,00092,172,288
11May 26, 2021 19:1115,234163,767,747115,688,00022,938,00092,200,960
12May 26, 2021 19:1115,277166,088,342109,015,00030,004,00092,200,960