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 17:51Joad NacerJoad NacerScore: 3,621Success
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 17:513,40858,860,60620,010,00011,005,00092,942,336
2May 22, 2024 17:513,40960,903,31421,013,00010,006,00092,958,720
3May 22, 2024 17:513,41861,144,56120,065,00011,035,00092,925,952
4May 22, 2024 17:513,42157,953,24920,084,00011,046,00092,917,760
5May 22, 2024 17:513,42858,089,14020,126,00011,069,00093,020,160
6May 22, 2024 17:513,43156,185,47620,142,00011,078,00092,839,936
7May 22, 2024 17:513,43254,555,28620,151,00011,083,00092,876,800
8May 22, 2024 17:513,44055,618,67320,198,00011,109,00092,909,568
9May 22, 2024 17:513,44254,921,30220,205,00011,113,00092,864,512
10May 22, 2024 17:513,44953,999,80421,261,00010,124,00092,889,088
11May 22, 2024 17:513,47657,722,96819,770,00011,862,00092,860,416
12May 22, 2024 17:513,48058,102,24919,793,00011,875,00092,905,472
13May 22, 2024 17:513,48057,321,05420,784,00010,887,00092,921,856
14May 22, 2024 17:513,48263,911,42520,797,00010,893,00092,975,104
15May 22, 2024 17:513,48558,117,59619,822,00011,893,00092,909,568
16May 22, 2024 17:513,48956,584,29119,844,00011,906,00092,897,280
17May 22, 2024 17:513,49057,566,09520,841,00010,916,00093,192,192
18May 22, 2024 17:513,49661,860,23219,886,00011,932,00092,917,760
19May 22, 2024 17:513,50059,293,92421,894,0009,952,00092,839,936
20May 22, 2024 17:513,50059,642,29319,909,00011,945,00092,938,240
21May 22, 2024 17:513,50056,018,21020,903,00010,949,00092,925,952
22May 22, 2024 17:513,50160,006,77019,911,00011,946,00092,938,240
23May 22, 2024 17:513,50160,623,48019,911,00011,946,00092,921,856
24May 22, 2024 17:513,51657,819,46719,998,00011,998,00092,880,896
25May 22, 2024 17:513,51762,840,63320,003,00012,002,00092,925,952
26May 22, 2024 17:513,52158,255,49620,023,00012,014,00092,962,816
27May 22, 2024 17:513,593102,456,51632,693,170094,482,432
28May 22, 2024 17:513,59588,284,55032,714,317094,752,768
29May 22, 2024 17:513,599102,729,70132,749,853094,490,624
30May 22, 2024 17:513,60297,505,28332,778,383094,490,624
31May 22, 2024 17:513,602104,025,29732,775,117094,482,432
32May 22, 2024 17:513,604107,207,99532,796,468094,486,528
33May 22, 2024 17:513,60884,834,86832,828,553094,621,696
34May 22, 2024 17:513,618102,619,51532,925,275094,486,528
35May 22, 2024 17:513,62088,978,12932,944,415094,482,432
36May 22, 2024 17:513,62093,261,76532,939,691094,486,528
37May 22, 2024 17:513,62191,171,01532,949,026094,490,624
38May 22, 2024 17:513,62489,973,98032,978,331094,490,624
39May 22, 2024 17:513,628111,837,05233,018,161094,490,624
40May 22, 2024 17:513,631100,210,91433,040,406094,756,864
41May 22, 2024 17:513,63177,244,65633,038,548094,490,624
42May 22, 2024 17:513,63298,402,99033,055,048094,482,432
43May 22, 2024 17:513,637112,080,57433,093,642094,625,792
44May 22, 2024 17:513,63896,208,71433,104,041094,490,624
45May 22, 2024 17:513,85261,626,92420,029,00015,022,00093,143,040
46May 22, 2024 17:513,93362,025,03620,879,00014,914,00093,163,520
47May 22, 2024 17:514,06068,043,72721,966,00014,977,00093,151,232
48May 22, 2024 17:514,11064,213,34121,230,00016,175,00093,204,480
49May 22, 2024 17:514,15763,645,17420,905,00016,923,00093,089,792
50May 22, 2024 17:514,21362,472,98621,189,00017,153,00093,138,944
51May 22, 2024 17:514,42467,524,82421,136,00019,123,00093,114,368
52May 22, 2024 17:514,56265,565,43321,263,00020,251,00093,126,656
53May 22, 2024 17:514,64871,398,25621,150,00021,150,00093,138,944
54May 22, 2024 17:515,29774,275,35823,095,00025,104,00093,028,352
55May 22, 2024 17:516,10684,691,04324,245,00031,316,00093,253,632
56May 22, 2024 17:516,57785,135,32423,939,00035,908,00093,102,080
57May 22, 2024 17:516,67786,868,53025,897,00034,861,00093,278,208
58May 22, 2024 17:516,98194,801,41224,202,00039,328,00093,319,168
59May 22, 2024 17:517,01294,449,75124,924,00038,882,00093,208,576
60May 22, 2024 17:517,19088,764,11724,158,00041,269,00093,196,288
61May 22, 2024 17:517,21392,858,90924,235,00041,402,00093,192,192
62May 22, 2024 17:517,27991,830,98725,090,00041,147,00093,224,960
63May 22, 2024 17:517,38290,467,17925,067,00042,113,00093,245,440
64May 22, 2024 17:517,41390,966,49424,165,00043,295,00093,208,576
65May 22, 2024 17:517,431103,887,04424,221,00043,397,00093,229,056
66May 22, 2024 17:517,44696,071,57823,916,00043,846,00093,126,656
67May 22, 2024 17:517,453103,222,27123,936,00043,883,00093,351,936
68May 22, 2024 17:517,46390,440,28223,971,00043,946,00093,224,960
69May 22, 2024 17:517,49293,355,04325,063,00043,110,00093,286,400
70May 22, 2024 17:517,53399,989,74326,211,00042,341,00093,319,168
71May 22, 2024 17:517,53498,577,49725,206,00043,354,00093,130,752
72May 22, 2024 17:517,558102,029,62423,921,00044,853,00093,237,248