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 listJun 6, 2021 18:58Yuriy LyfenkoYuriy LyfenkoScore: 9,647Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 6, 2021 18:584,664600,132,82042,441,835094,654,464
2Jun 6, 2021 18:584,683595,892,10242,612,269094,646,272
3Jun 6, 2021 18:584,699604,596,72942,759,330094,650,368
4Jun 6, 2021 18:589,605616,353,22269,531,00017,879,00094,552,064
5Jun 6, 2021 18:589,609615,255,38069,554,00017,885,00094,547,968
6Jun 6, 2021 18:589,611614,444,24169,569,00017,889,00094,543,872
7Jun 6, 2021 18:589,647614,745,69471,825,00015,961,00094,547,968
8Jun 6, 2021 18:589,650610,398,85569,852,00017,962,00094,547,968
9Jun 6, 2021 18:589,671613,110,43974,009,00014,001,00094,552,064
10Jun 6, 2021 18:589,840620,636,05266,659,00022,882,00092,979,200
11Jun 6, 2021 18:589,870613,019,01270,854,00018,961,00093,245,440
12Jun 6, 2021 18:5810,063626,651,25268,683,00022,894,00093,245,440