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 19:17Yuriy LyfenkoYuriy LyfenkoScore: 9,635Success
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 19:174,745144,793,40243,182,950094,666,752
2May 26, 2021 19:174,746103,671,14143,184,509094,658,560
3May 26, 2021 19:174,936137,319,80644,921,950094,654,464
4May 26, 2021 19:179,620111,006,86169,638,00017,906,00094,683,136
5May 26, 2021 19:179,631111,913,88068,719,00018,922,00094,687,232
6May 26, 2021 19:179,632112,510,19669,520,00018,135,00094,679,040
7May 26, 2021 19:179,635112,196,09069,747,00017,935,00094,552,064
8May 26, 2021 19:179,658116,401,12670,911,00016,978,00094,679,040
9May 26, 2021 19:179,658110,636,60369,913,00017,977,00094,683,136
10May 26, 2021 19:179,909114,719,19971,136,00019,036,00092,979,200
11May 26, 2021 19:1710,006118,947,29370,043,00021,012,00093,097,984
12May 26, 2021 19:1710,141116,857,96472,222,00020,061,00093,245,440