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 19:04Yuriy LyfenkoYuriy LyfenkoScore: 9,625Success
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 19:044,6291,103,251,05542,126,406094,658,560
2Jun 6, 2021 19:044,6541,098,968,53842,348,260094,654,464
3Jun 6, 2021 19:044,7091,094,604,99442,848,655094,662,656
4Jun 6, 2021 19:049,5511,110,628,82270,927,00015,983,00094,547,968
5Jun 6, 2021 19:049,5961,111,840,11471,265,00016,059,00094,547,968
6Jun 6, 2021 19:049,6011,114,182,96272,127,00015,238,00094,547,968
7Jun 6, 2021 19:049,6251,111,338,52769,464,00018,121,00094,552,064
8Jun 6, 2021 19:049,6261,112,220,94670,478,00017,116,00094,547,968
9Jun 6, 2021 19:049,6361,110,839,98467,532,00020,158,00092,983,296
10Jun 6, 2021 19:049,7021,114,854,25071,035,00017,251,00092,979,200
11Jun 6, 2021 19:0410,0741,119,683,46570,519,00021,155,00093,241,344
12Jun 6, 2021 19:0410,1351,114,954,10075,002,00017,230,00093,241,344