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 01:00Yurkov AlekseyYurkov AlekseyScore: 12,741Success
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 01:005,854158,124,21753,270,329092,557,312
2May 28, 2021 01:005,876135,821,15253,470,314092,561,408
3May 28, 2021 01:005,879113,291,03653,496,929092,692,480
4May 28, 2021 01:0012,731142,048,376102,872,00012,983,00092,643,328
5May 28, 2021 01:0012,736139,352,63699,910,00015,985,00092,573,696
6May 28, 2021 01:0012,738138,803,66399,929,00015,988,00092,704,768
7May 28, 2021 01:0012,741138,449,401103,946,00011,993,00092,471,296
8May 28, 2021 01:0012,741144,095,06498,950,00016,991,00092,471,296
9May 28, 2021 01:0012,743144,889,11696,969,00018,993,00092,463,104
10May 28, 2021 01:0012,755141,874,78797,062,00019,012,00092,643,328
11May 28, 2021 01:0012,838138,618,98097,858,00018,972,00092,180,480
12May 28, 2021 01:0012,861151,087,31799,029,00018,005,00092,065,792