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 21:07Yurkov AlekseyYurkov AlekseyScore: 14,265Success
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 21:0710,582155,765,49196,292,280092,561,408
2May 26, 2021 21:0710,613166,137,43096,573,928092,553,216
3May 26, 2021 21:0710,616157,139,67796,606,976092,565,504
4May 26, 2021 21:0714,229159,869,317111,557,00017,928,00092,446,720
5May 26, 2021 21:0714,241155,275,559110,656,00018,941,00092,700,672
6May 26, 2021 21:0714,246152,516,154114,682,00014,958,00092,463,104
7May 26, 2021 21:0714,265151,622,990112,836,00016,975,00092,549,120
8May 26, 2021 21:0714,266158,075,524113,846,00015,978,00092,557,312
9May 26, 2021 21:0714,271154,625,998114,879,00014,984,00092,704,768
10May 26, 2021 21:0714,294157,088,182114,190,00015,887,00092,569,600
11May 26, 2021 21:0714,319156,596,169113,264,00017,039,00092,008,448
12May 26, 2021 21:0714,396154,402,766112,001,00019,000,00092,184,576