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 28, 2021 00:27Yurkov AlekseyYurkov AlekseyScore: 13,052Success
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 28, 2021 00:276,103122,555,53255,538,595092,565,504
2May 28, 2021 00:276,115113,415,78455,646,271092,565,504
3May 28, 2021 00:276,119121,862,58255,687,280092,561,408
4May 28, 2021 00:2713,020142,466,124104,546,00013,939,00092,463,104
5May 28, 2021 00:2713,046142,860,41598,764,00019,952,00092,463,104
6May 28, 2021 00:2713,049140,609,179103,780,00014,968,00092,553,216
7May 28, 2021 00:2713,052140,666,233100,808,00017,965,00092,463,104
8May 28, 2021 00:2713,066145,078,977102,913,00015,986,00092,700,672
9May 28, 2021 00:2713,086142,161,814101,073,00018,013,00092,528,640
10May 28, 2021 00:2713,215147,389,355101,215,00019,040,00092,180,480
11May 28, 2021 00:2713,231150,864,273101,341,00019,064,00092,127,232
12May 28, 2021 00:2713,565151,651,012106,381,00017,061,00092,205,056