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 15:21Yuriy LyfenkoYuriy LyfenkoScore: 14,227Success
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 15:219,000139,041,23681,902,574094,670,848
2May 26, 2021 15:219,017143,994,38682,052,495094,679,040
3May 26, 2021 15:219,090139,901,68082,721,650094,781,440
4May 26, 2021 15:2114,205150,800,04782,167,00047,095,00094,580,736
5May 26, 2021 15:2114,217163,905,42781,235,00048,139,00094,601,216
6May 26, 2021 15:2114,227156,101,70578,283,00051,185,00094,785,536
7May 26, 2021 15:2114,227157,017,96583,302,00046,167,00094,629,888
8May 26, 2021 15:2114,245158,338,56084,759,00044,872,00093,167,616
9May 26, 2021 15:2114,246159,095,34684,764,00044,875,00094,629,888
10May 26, 2021 15:2114,327152,365,23982,238,00048,139,00092,971,008
11May 26, 2021 15:2114,915161,778,44180,836,00054,888,00093,057,024
12May 26, 2021 15:2115,059170,703,60880,024,00057,017,00093,130,752