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 28, 2021 00:41Yurkov AlekseyYurkov AlekseyScore: 12,968Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 28, 2021 00:416,056115,620,66155,109,027092,565,504
2May 28, 2021 00:416,064123,845,18655,182,195092,557,312
3May 28, 2021 00:416,070119,461,85955,235,542092,557,312
4May 28, 2021 00:4112,944142,760,647100,824,00016,970,00092,704,768
5May 28, 2021 00:4112,956151,727,76399,913,00017,984,00092,463,104
6May 28, 2021 00:4112,967149,318,50399,998,00017,999,00092,667,904
7May 28, 2021 00:4112,968143,710,480102,007,00016,001,00092,704,768
8May 28, 2021 00:4112,969142,040,463103,018,00015,002,00092,463,104
9May 28, 2021 00:4113,002146,391,315102,272,00016,042,00092,704,768
10May 28, 2021 00:4113,283146,716,855100,899,00019,980,00092,151,808
11May 28, 2021 00:4113,306148,397,110101,070,00020,013,00092,073,984
12May 28, 2021 00:4113,405151,717,34998,985,00022,996,00092,176,384