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:36Yurkov AlekseyYurkov AlekseyScore: 13,013Success
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:366,094111,786,47255,459,702092,684,288
2May 28, 2021 00:366,106120,367,94155,566,594092,553,216
3May 28, 2021 00:366,108115,353,62955,578,923092,561,408
4May 28, 2021 00:3613,002149,151,204100,267,00018,048,00092,463,104
5May 28, 2021 00:3613,006142,052,697104,315,00014,042,00092,540,928
6May 28, 2021 00:3613,011145,883,288103,350,00015,051,00092,635,136
7May 28, 2021 00:3613,013145,556,415101,361,00017,060,00092,643,328
8May 28, 2021 00:3613,021148,963,589103,431,00015,062,00092,471,296
9May 28, 2021 00:3613,030146,793,283103,502,00015,073,00092,463,104
10May 28, 2021 00:3613,041153,657,29698,725,00019,944,00092,102,656
11May 28, 2021 00:3613,339143,297,150103,330,00018,057,00092,078,080
12May 28, 2021 00:3613,349145,082,966102,402,00019,075,00092,155,904