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:29Yuriy LyfenkoYuriy LyfenkoError
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:3300000exit with code 1: 305 42791 235
2May 26, 2021 16:294,834115,380,35043,991,257094,732,288
3May 26, 2021 16:294,874107,219,27944,354,753094,736,384
4May 26, 2021 16:295,197133,748,51447,292,805094,715,904
5May 26, 2021 16:299,862118,397,20571,792,00017,948,00094,552,064
6May 26, 2021 16:299,865112,555,20471,818,00017,954,00094,765,056
7May 26, 2021 16:299,866111,323,83171,827,00017,956,00094,760,960
8May 26, 2021 16:299,882111,281,24869,943,00019,983,00094,765,056
9May 26, 2021 16:299,895111,407,38771,035,00019,009,00094,769,152
10May 26, 2021 16:299,930118,100,18075,301,00015,060,00094,760,960
11May 26, 2021 16:2910,151119,108,76783,338,0009,036,00093,175,808
12May 26, 2021 16:2910,188116,323,20466,790,00025,918,00093,188,096
13May 26, 2021 16:2910,234117,921,12188,121,0005,006,00093,196,288