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:32Yurkov AlekseyYurkov AlekseyScore: 13,025Success
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:326,146111,660,99555,929,027092,561,408
2May 28, 2021 00:326,171113,463,40456,153,702092,565,504
3May 28, 2021 00:326,186129,978,49256,292,048092,561,408
4May 28, 2021 00:3212,988141,795,773100,159,00018,028,00092,463,104
5May 28, 2021 00:3212,995139,206,888100,214,00018,038,00092,594,176
6May 28, 2021 00:3213,007143,918,403103,319,00015,046,00092,606,464
7May 28, 2021 00:3213,025144,497,57299,600,00018,924,00092,463,104
8May 28, 2021 00:3213,033148,817,162103,653,00014,949,00092,463,104
9May 28, 2021 00:3213,040143,600,84699,721,00018,947,00092,524,544
10May 28, 2021 00:3213,163146,860,515101,818,00017,967,00092,176,384
11May 28, 2021 00:3213,261152,361,00199,731,00020,943,00092,188,672
12May 28, 2021 00:3213,302143,267,527101,044,00020,008,00092,205,056