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 16:39Yuriy LyfenkoYuriy LyfenkoScore: 9,880Success
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 16:394,800118,490,95643,679,586094,658,560
2May 26, 2021 16:394,830104,643,92443,953,330094,654,464
3May 26, 2021 16:394,934127,534,60944,900,231094,711,808
4May 26, 2021 16:399,858115,295,37873,758,00015,947,00094,683,136
5May 26, 2021 16:399,871111,085,97672,859,00016,967,00094,552,064
6May 26, 2021 16:399,874112,346,99970,887,00018,969,00094,789,632
7May 26, 2021 16:399,880115,267,99169,931,00019,980,00094,552,064
8May 26, 2021 16:399,884117,159,54173,955,00015,990,00094,666,752
9May 26, 2021 16:399,931117,066,11675,313,00015,062,00094,683,136
10May 26, 2021 16:399,982114,283,51267,877,00022,958,00092,983,296
11May 26, 2021 16:3910,273116,504,97589,460,0004,020,00093,241,344
12May 26, 2021 16:3910,310115,886,15062,546,00031,273,00093,245,440