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:05Yuriy LyfenkoYuriy LyfenkoScore: 9,744Success
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:054,806112,554,99843,734,859094,662,656
2May 26, 2021 19:054,901121,033,45744,598,528094,773,248
3May 26, 2021 19:054,942116,954,55444,973,792094,654,464
4May 26, 2021 19:059,720113,128,81074,382,00014,072,00094,801,920
5May 26, 2021 19:059,732118,602,88574,627,00013,930,00094,547,968
6May 26, 2021 19:059,737119,013,33374,669,00013,938,00094,683,136
7May 26, 2021 19:059,744118,591,17774,719,00013,947,00094,687,232
8May 26, 2021 19:059,764117,778,58871,881,00016,971,00094,547,968
9May 26, 2021 19:059,787114,933,55174,054,00015,010,00094,683,136
10May 26, 2021 19:059,795113,130,03275,110,00014,020,00093,106,176
11May 26, 2021 19:059,890117,467,15474,002,00016,000,00092,979,200
12May 26, 2021 19:0510,018114,733,03084,152,0007,012,00093,245,440