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 27, 2021 13:18Yurkov AlekseyYurkov AlekseyScore: 8,477Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 27, 2021 13:188,416105,505,62960,670,00015,913,00092,708,864
2May 27, 2021 13:188,418103,654,77860,686,00015,917,00092,700,672
3May 27, 2021 13:188,425100,219,76060,734,00015,930,00092,557,312
4May 27, 2021 13:188,436102,787,63861,816,00014,955,00092,446,720
5May 27, 2021 13:188,463105,068,53460,013,00017,003,00092,463,104
6May 27, 2021 13:188,47298,859,26561,076,00016,020,00092,549,120
7May 27, 2021 13:188,477106,528,01858,105,00019,034,00092,471,296
8May 27, 2021 13:188,672107,832,54261,937,00016,982,00091,942,912
9May 27, 2021 13:188,773108,575,49461,870,00017,962,00092,209,152
10May 27, 2021 13:188,897135,733,13080,961,860092,561,408
11May 27, 2021 13:188,904146,686,01081,022,347092,557,312
12May 27, 2021 13:188,929134,978,69781,254,298092,553,216