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 02:29Yuriy LyfenkoYuriy LyfenkoScore: 14,233Success
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 02:2910,896170,698,60599,151,188094,724,096
2May 26, 2021 02:2910,932155,658,80099,480,924094,707,712
3May 26, 2021 02:2910,974153,623,02899,861,191094,777,344
4May 26, 2021 02:2914,218150,246,29581,239,00048,142,00094,752,768
5May 26, 2021 02:2914,230156,363,61980,304,00049,186,00094,543,872
6May 26, 2021 02:2914,232154,088,28782,322,00047,185,00094,580,736
7May 26, 2021 02:2914,233156,522,79185,343,00044,177,00094,568,448
8May 26, 2021 02:2914,237159,654,24179,343,00050,217,00094,654,464
9May 26, 2021 02:2914,239154,621,32682,729,00046,846,00094,597,120
10May 26, 2021 02:2914,315155,901,65081,166,00049,100,00093,179,904
11May 26, 2021 02:2914,383157,744,84977,931,00052,953,00093,102,080
12May 26, 2021 02:2914,678162,252,80482,350,00051,217,00093,032,448