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 21:06Yurkov AlekseyYurkov AlekseyError
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 21:0600000Died or killed
2May 26, 2021 21:0610,599152,459,70896,447,886092,565,504
3May 26, 2021 21:0610,629187,993,76696,721,478092,557,312
4May 26, 2021 21:0610,906163,853,94799,246,681092,557,312
5May 26, 2021 21:0614,227153,710,772110,546,00018,922,00092,708,864
6May 26, 2021 21:0614,245154,522,812112,674,00016,951,00092,463,104
7May 26, 2021 21:0614,250157,318,473114,714,00014,962,00092,557,312
8May 26, 2021 21:0614,254157,726,068112,753,00016,962,00092,692,480
9May 26, 2021 21:0614,279156,455,201112,948,00016,992,00092,446,720
10May 26, 2021 21:0614,292151,422,511116,050,00014,006,00092,532,736
11May 26, 2021 21:0614,419152,284,276113,182,00018,029,00092,033,024
12May 26, 2021 21:0614,517155,608,406114,089,00018,014,00092,188,672
13May 26, 2021 21:0614,552159,026,543114,369,00018,058,00092,028,928