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:59Yurkov AlekseyYurkov AlekseyScore: 12,782Success
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:595,889122,583,88653,587,449092,569,600
2May 28, 2021 00:595,898120,335,49253,673,653092,565,504
3May 28, 2021 00:595,913126,393,30753,808,820092,553,216
4May 28, 2021 00:5912,724144,033,85199,815,00015,970,00092,450,816
5May 28, 2021 00:5912,765140,222,66998,140,00018,025,00092,643,328
6May 28, 2021 00:5912,769141,001,011100,168,00016,026,00092,594,176
7May 28, 2021 00:5912,782142,883,97497,262,00019,051,00092,626,944
8May 28, 2021 00:5912,784146,479,176101,290,00015,043,00092,463,104
9May 28, 2021 00:5912,825142,136,54997,755,00018,952,00092,700,672
10May 28, 2021 00:5912,828139,227,378101,773,00014,966,00092,176,384
11May 28, 2021 00:5913,015142,380,297101,376,00017,063,00092,209,152
12May 28, 2021 00:5913,090140,159,925102,105,00017,017,00092,184,576