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 12:49Yurkov AlekseyYurkov AlekseyScore: 8,964Success
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 12:498,598101,194,14262,196,00016,050,00092,463,104
2May 27, 2021 12:498,59997,342,18961,198,00017,055,00092,569,600
3May 27, 2021 12:498,605105,245,63562,242,00016,062,00092,471,296
4May 27, 2021 12:498,619104,463,73363,347,00015,082,00092,463,104
5May 27, 2021 12:498,638107,657,63360,693,00017,909,00092,471,296
6May 27, 2021 12:498,644112,065,75663,723,00014,935,00092,463,104
7May 27, 2021 12:498,964110,395,08959,415,00022,154,00092,192,768
8May 27, 2021 12:498,977105,933,32361,768,00019,925,00092,286,976
9May 27, 2021 12:499,049108,814,64463,267,00019,080,00092,188,672
10May 27, 2021 12:4910,295153,680,80193,681,294092,565,504
11May 27, 2021 12:4910,301181,015,56893,743,559092,569,600
12May 27, 2021 12:4910,313161,640,55893,851,830092,553,216