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:29Yurkov AlekseyYurkov AlekseyScore: 13,041Success
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:296,167117,298,22556,123,253092,569,600
2May 28, 2021 00:296,182125,880,13256,260,010092,565,504
3May 28, 2021 00:296,210135,071,17856,514,261092,569,600
4May 28, 2021 00:2913,019143,984,89999,557,00018,915,00092,704,768
5May 28, 2021 00:2913,029144,252,701101,629,00016,938,00092,643,328
6May 28, 2021 00:2913,035145,505,316103,668,00014,952,00092,622,848
7May 28, 2021 00:2913,041145,257,151100,719,00017,950,00092,553,216
8May 28, 2021 00:2913,045144,849,607101,752,00016,958,00092,700,672
9May 28, 2021 00:2913,054143,881,392100,826,00017,969,00092,565,504
10May 28, 2021 00:2913,083153,047,448101,046,00018,008,00092,520,448
11May 28, 2021 00:2913,123145,237,304100,350,00019,066,00092,180,480
12May 28, 2021 00:2913,403146,432,457101,976,00019,995,00092,155,904