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 listJul 17, 2021 10:30Yurkov AlekseyYurkov AlekseyScore: 12,807Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 17, 2021 10:305,966120,487,06654,288,123092,659,712
2Jul 17, 2021 10:305,976113,403,65454,378,150092,659,712
3Jul 17, 2021 10:306,017107,037,37154,750,315092,659,712
4Jul 17, 2021 10:3012,785139,335,641106,318,00010,030,00092,676,096
5Jul 17, 2021 10:3012,795143,275,26296,360,00020,075,00092,512,256
6Jul 17, 2021 10:3012,800142,198,27796,399,00020,083,00092,516,352
7Jul 17, 2021 10:3012,807143,564,06797,619,00018,926,00092,684,288
8Jul 17, 2021 10:3012,822148,198,773103,714,00012,964,00092,471,296
9Jul 17, 2021 10:3012,845141,399,617104,899,00011,988,00092,463,104
10Jul 17, 2021 10:3012,850141,117,811104,941,00011,993,00092,471,296
11Jul 17, 2021 10:3013,046148,165,38689,788,00028,931,00091,942,912
12Jul 17, 2021 10:3013,162153,602,14297,814,00021,958,00092,205,056