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:16Yuriy LyfenkoYuriy LyfenkoScore: 9,659Success
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:164,71698,407,60942,912,329094,662,656
2May 26, 2021 19:164,753105,151,33743,248,383094,658,560
3May 26, 2021 19:164,827110,817,22343,922,127094,654,464
4May 26, 2021 19:169,631113,787,30970,710,00016,930,00094,801,920
5May 26, 2021 19:169,651108,416,11069,857,00017,963,00094,547,968
6May 26, 2021 19:169,655111,744,33769,890,00017,971,00094,683,136
7May 26, 2021 19:169,659113,229,14768,921,00018,978,00094,679,040
8May 26, 2021 19:169,674109,848,97769,023,00019,006,00094,683,136
9May 26, 2021 19:169,745112,182,54765,764,00022,917,00092,979,200
10May 26, 2021 19:169,953116,597,67173,461,00017,107,00093,241,344
11May 26, 2021 19:1610,126115,832,93474,118,00018,028,00093,245,440
12May 26, 2021 19:1610,150116,169,50573,292,00019,076,00093,245,440