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:01Yurkov AlekseyYurkov AlekseyScore: 14,298Success
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:0110,304153,693,11493,762,574092,565,504
2May 26, 2021 19:0110,340159,557,10294,091,412092,557,312
3May 26, 2021 19:0110,499173,012,56595,544,237092,557,312
4May 26, 2021 19:0114,262153,494,029115,809,00013,977,00092,692,480
5May 26, 2021 19:0114,276152,308,351112,922,00016,988,00092,590,080
6May 26, 2021 19:0114,288151,559,580115,018,00015,002,00092,700,672
7May 26, 2021 19:0114,298156,630,189116,097,00014,011,00092,463,104
8May 26, 2021 19:0114,317148,044,532114,254,00016,035,00092,463,104
9May 26, 2021 19:0114,322157,646,121114,290,00016,040,00092,700,672
10May 26, 2021 19:0114,420153,467,454115,199,00016,027,00091,947,008
11May 26, 2021 19:0114,697159,385,983114,776,00018,963,00092,266,496
12May 26, 2021 19:0114,856161,486,820113,156,00022,030,00092,209,152