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 18:56Yurkov AlekseyYurkov AlekseyScore: 14,296Success
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 18:5610,626164,345,57296,693,324092,573,696
2May 26, 2021 18:5610,629267,423,89296,719,567092,569,600
3May 26, 2021 18:5610,832158,665,39098,566,942092,557,312
4May 26, 2021 18:5614,262155,391,037113,814,00015,973,00092,528,640
5May 26, 2021 18:5614,277156,845,097111,933,00017,989,00092,565,504
6May 26, 2021 18:5614,281154,981,329115,961,00013,995,00092,463,104
7May 26, 2021 18:5614,296158,430,675116,081,00014,009,00092,459,008
8May 26, 2021 18:5614,318154,552,422120,271,00010,022,00092,459,008
9May 26, 2021 18:5614,352156,878,714112,661,00017,946,00092,459,008
10May 26, 2021 18:5614,360157,623,286118,705,00011,970,00091,930,624
11May 26, 2021 18:5614,380153,255,120115,873,00014,983,00091,934,720
12May 26, 2021 18:5614,483159,192,532113,824,00017,972,00091,934,720