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 listAug 21, 2021 19:01Yuriy LyfenkoYuriy LyfenkoScore: 4,644Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 21, 2021 19:014,613567,927,09925,985,00015,990,00094,666,752
2Aug 21, 2021 19:014,615610,219,82041,995,390094,629,888
3Aug 21, 2021 19:014,621603,597,70142,052,922094,756,864
4Aug 21, 2021 19:014,640610,555,76342,225,014094,629,888
5Aug 21, 2021 19:014,641566,398,26424,132,00018,099,00094,666,752
6Aug 21, 2021 19:014,644566,765,95822,135,00020,122,00094,666,752
7Aug 21, 2021 19:014,644563,942,28525,156,00017,106,00094,662,656
8Aug 21, 2021 19:014,658563,951,98624,222,00018,166,00094,646,272
9Aug 21, 2021 19:014,689564,563,86422,822,00019,845,00094,666,752
10Aug 21, 2021 19:014,724568,011,00027,993,00014,996,00093,089,792
11Aug 21, 2021 19:014,788574,226,88825,747,00017,825,00093,081,600
12Aug 21, 2021 19:014,993576,613,23825,244,00020,195,00093,093,888