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 26, 2021 17:40Yurkov AlekseyYurkov AlekseyScore: 14,315Success
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 26, 2021 17:4010,326158,887,66893,965,683092,565,504
2May 26, 2021 17:4010,347173,086,80094,160,951092,557,312
3May 26, 2021 17:4010,369188,932,88694,354,547092,549,120
4May 26, 2021 17:4014,285157,591,457113,998,00015,999,00092,700,672
5May 26, 2021 17:4014,292157,217,794116,048,00014,005,00092,602,368
6May 26, 2021 17:4014,304159,610,079114,148,00016,020,00092,565,504
7May 26, 2021 17:4014,315163,042,558115,354,00014,916,00092,459,008
8May 26, 2021 17:4014,319162,876,442114,385,00015,914,00092,700,672
9May 26, 2021 17:4014,327159,423,238113,329,00017,049,00092,549,120
10May 26, 2021 17:4014,547153,665,188115,329,00017,048,00092,200,960
11May 26, 2021 17:4014,600157,832,961111,881,00020,977,00092,311,552
12May 26, 2021 17:4014,606161,482,737109,931,00022,985,00092,065,792