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:59Yuriy LyfenkoYuriy LyfenkoScore: 9,902Success
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:594,761119,146,40743,321,031094,654,464
2May 26, 2021 16:594,819107,509,54043,849,011094,658,560
3May 26, 2021 16:594,831109,059,70443,961,959094,646,272
4May 26, 2021 16:599,878117,996,43670,910,00018,976,00094,674,944
5May 26, 2021 16:599,892116,095,00572,012,00018,003,00094,683,136
6May 26, 2021 16:599,896121,170,76273,041,00017,009,00094,552,064
7May 26, 2021 16:599,902115,213,14074,090,00016,019,00094,547,968
8May 26, 2021 16:599,905112,568,96772,109,00018,027,00094,547,968
9May 26, 2021 16:599,912113,818,55876,167,00014,030,00094,679,040
10May 26, 2021 16:5910,078118,065,80563,801,00027,913,00093,110,272
11May 26, 2021 16:5910,082113,401,91061,830,00029,918,00093,114,368
12May 26, 2021 16:5910,148121,789,07785,321,0007,026,00093,106,176