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 18:46Yurkov AlekseyYurkov AlekseyScore: 14,295Success
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 18:4610,607169,621,66296,524,597092,553,216
2May 26, 2021 18:4610,647149,484,01696,884,199092,557,312
3May 26, 2021 18:4610,724172,137,27597,589,775092,561,408
4May 26, 2021 18:4614,286157,059,917113,000,00017,000,00092,459,008
5May 26, 2021 18:4614,290156,715,342113,037,00017,005,00092,459,008
6May 26, 2021 18:4614,292152,491,596114,048,00016,006,00092,704,768
7May 26, 2021 18:4614,295157,705,059114,072,00016,010,00092,590,080
8May 26, 2021 18:4614,308152,850,658114,176,00016,024,00092,704,768
9May 26, 2021 18:4614,329156,506,498114,342,00016,048,00092,459,008
10May 26, 2021 18:4614,430163,080,228109,262,00022,053,00092,184,576
11May 26, 2021 18:4614,459157,416,305115,630,00015,949,00092,196,864
12May 26, 2021 18:4614,518154,444,201115,098,00017,014,00092,184,576