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 22, 2024 00:09Joad NacerJoad NacerScore: 3,804Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 22, 2024 00:093,49760,206,37721,876,0009,943,00093,114,368
2May 22, 2024 00:103,52362,348,61721,040,00011,021,00092,876,800
3May 22, 2024 00:093,58157,642,35721,725,00010,862,00092,930,048
4May 22, 2024 00:103,58756,901,95120,775,00011,871,00092,901,376
5May 22, 2024 00:093,59559,364,42720,820,00011,897,00092,905,472
6May 22, 2024 00:093,59965,494,54120,839,00011,908,00092,864,512
7May 22, 2024 00:103,62160,044,84620,967,00011,981,00092,930,048
8May 22, 2024 00:093,75792,535,42534,190,413094,740,480
9May 22, 2024 00:093,758109,930,43534,197,324094,486,528
10May 22, 2024 00:103,760103,612,83934,213,720094,605,312
11May 22, 2024 00:103,782112,222,54034,419,183094,609,408
12May 22, 2024 00:103,790108,290,34334,487,898094,490,624
13May 22, 2024 00:093,80498,098,31334,619,374094,613,504
14May 22, 2024 00:103,95970,157,46422,018,00014,011,00093,159,424
15May 22, 2024 00:104,27466,034,76922,937,00015,956,00093,159,424
16May 22, 2024 00:104,66169,587,77423,229,00019,189,00093,159,424
17May 22, 2024 00:095,07470,443,07323,085,00023,085,00093,085,696
18May 22, 2024 00:095,32474,075,23623,215,00025,233,00093,126,656
19May 22, 2024 00:107,54695,738,64426,255,00042,412,00093,245,440
20May 22, 2024 00:097,55895,834,71024,918,00043,856,00093,184,000
21May 22, 2024 00:107,60193,687,94425,062,00044,110,00093,130,752
22May 22, 2024 00:097,62688,751,91426,150,00043,248,00093,208,576
23May 22, 2024 00:107,64198,039,23526,200,00043,331,00093,245,440
24May 22, 2024 00:097,64596,244,10626,213,00043,353,00093,204,480