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 9, 2024 23:27Joad NacerJoad NacerScore: 3,956Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 9, 2024 23:273,74261,239,09623,038,00011,018,00092,901,376
2May 9, 2024 23:273,75063,526,04023,082,00011,039,00093,011,968
3May 9, 2024 23:273,76159,621,15424,157,00010,065,00093,155,328
4May 9, 2024 23:293,77457,501,79423,233,00011,111,00092,889,088
5May 9, 2024 23:293,77565,014,71523,238,00011,113,00092,913,664
6May 9, 2024 23:293,79360,594,45424,362,00010,151,00092,909,568
7May 9, 2024 23:293,81562,038,76622,812,00011,902,00093,196,288
8May 9, 2024 23:293,82966,876,85922,895,00011,945,00092,901,376
9May 9, 2024 23:273,83660,536,92422,941,00011,969,00092,966,912
10May 9, 2024 23:273,938107,485,84635,840,204094,486,528
11May 9, 2024 23:293,95295,408,75035,965,716094,486,528
12May 9, 2024 23:293,95398,724,59035,976,451094,490,624
13May 9, 2024 23:273,95697,165,26935,999,301094,478,336
14May 9, 2024 23:273,958114,036,86336,015,199094,597,120
15May 9, 2024 23:293,97793,612,57636,195,172094,478,336
16May 9, 2024 23:274,13767,103,09723,402,00014,244,00093,155,328
17May 9, 2024 23:294,36470,865,29423,829,00015,886,00093,138,944
18May 9, 2024 23:274,59173,438,74623,872,00017,904,00093,048,832
19May 9, 2024 23:296,61284,415,95626,073,00034,095,00093,229,056
20May 9, 2024 23:276,88199,502,02427,268,00035,347,00093,286,400
21May 9, 2024 23:296,98393,795,26927,233,00036,311,00093,188,096
22May 9, 2024 23:277,80099,235,52026,993,00043,989,00093,237,248
23May 9, 2024 23:277,81799,186,37527,052,00044,084,00093,339,648
24May 9, 2024 23:297,867105,714,47028,234,00043,360,00093,233,152