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 18:58Yurkov AlekseyYurkov AlekseyScore: 14,280Success
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 18:5810,326151,551,39693,967,337092,565,504
2May 26, 2021 18:5810,330149,922,22194,002,575092,561,408
3May 26, 2021 18:5810,372146,970,84794,381,419092,569,600
4May 26, 2021 18:5814,252152,733,829111,736,00017,957,00092,692,480
5May 26, 2021 18:5814,270154,899,945112,876,00016,981,00092,463,104
6May 26, 2021 18:5814,278155,686,121113,939,00015,991,00092,471,296
7May 26, 2021 18:5814,280155,763,994113,953,00015,993,00092,700,672
8May 26, 2021 18:5814,286153,872,819115,004,00015,000,00092,450,816
9May 26, 2021 18:5814,324156,908,451116,307,00014,037,00092,463,104
10May 26, 2021 18:5814,336155,984,293113,531,00016,930,00092,012,544
11May 26, 2021 18:5814,365156,799,346115,752,00014,968,00092,045,312
12May 26, 2021 18:5814,373154,137,518111,827,00018,970,00091,942,912