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 listJul 28, 2023 21:37Yurkov AlekseyYurkov AlekseyScore: 12,764Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 28, 2023 21:375,958107,983,29054,218,546092,561,408
2Jul 28, 2023 21:375,960115,198,25554,234,571092,565,504
3Jul 28, 2023 21:375,974117,306,45854,367,006092,557,312
4Jul 28, 2023 21:3712,718138,516,09988,793,00026,937,00092,651,520
5Jul 28, 2023 21:3712,752137,263,01497,034,00019,006,00092,688,384
6Jul 28, 2023 21:3712,761140,961,533107,119,0009,010,00092,692,480
7Jul 28, 2023 21:3712,764140,379,58597,129,00019,025,00092,471,296
8Jul 28, 2023 21:3712,765136,680,41089,121,00027,036,00092,463,104
9Jul 28, 2023 21:3712,782143,412,101101,273,00015,040,00092,532,736
10Jul 28, 2023 21:3712,790142,297,80192,306,00024,079,00091,910,144
11Jul 28, 2023 21:3712,825147,803,08997,752,00018,952,00091,947,008
12Jul 28, 2023 21:3713,064142,834,27098,901,00019,980,00092,082,176