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 02:44Yuriy LyfenkoYuriy LyfenkoScore: 14,468Success
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 02:4410,962165,025,54099,755,338094,773,248
2May 26, 2021 02:4410,978160,610,00399,895,570094,789,632
3May 26, 2021 02:4411,004168,449,461100,136,303094,748,672
4May 26, 2021 02:4414,445163,447,22883,286,00048,165,00094,547,968
5May 26, 2021 02:4414,453157,891,57288,348,00043,170,00094,560,256
6May 26, 2021 02:4414,462158,691,91880,758,00050,848,00094,564,352
7May 26, 2021 02:4414,468163,424,83379,793,00051,865,00094,601,216
8May 26, 2021 02:4414,479155,630,87384,844,00046,914,00094,765,056
9May 26, 2021 02:4414,499158,036,64179,964,00051,976,00094,785,536
10May 26, 2021 02:4414,873162,028,68487,221,00048,122,00093,237,248
11May 26, 2021 02:4415,157164,201,70084,955,00052,972,00093,179,904
12May 26, 2021 02:4415,305166,831,67988,175,00051,101,00093,270,016