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 01:01Joad NacerJoad NacerScore: 3,660Success
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 01:013,41057,498,44420,021,00011,011,00092,884,992
2May 22, 2024 01:013,41457,033,11020,046,00011,025,00092,917,760
3May 22, 2024 01:013,42956,438,93621,139,00010,066,00092,999,680
4May 22, 2024 01:013,43356,248,74521,161,00010,077,00092,897,280
5May 22, 2024 01:013,43453,151,02022,178,0009,073,00093,159,424
6May 22, 2024 01:013,43556,489,28220,165,00011,091,00092,917,760
7May 22, 2024 01:003,43755,768,15020,180,00011,099,00092,934,144
8May 22, 2024 01:003,44054,019,68420,196,00011,107,00092,897,280
9May 22, 2024 01:013,44853,223,20920,241,00011,132,00093,007,872
10May 22, 2024 01:013,46460,258,69421,355,00010,169,00092,962,816
11May 22, 2024 01:013,48861,033,45419,840,00011,904,00092,921,856
12May 22, 2024 01:013,49554,513,24420,875,00010,934,00092,897,280
13May 22, 2024 01:013,49556,077,48319,876,00011,925,00093,179,904
14May 22, 2024 01:013,49758,487,03819,888,00011,933,00092,893,184
15May 22, 2024 01:013,49955,864,58419,902,00011,941,00092,917,760
16May 22, 2024 01:013,49959,963,70719,900,00011,940,00092,930,048
17May 22, 2024 01:013,50059,726,54919,905,00011,943,00092,905,472
18May 22, 2024 01:013,50358,539,35719,924,00011,954,00093,143,040
19May 22, 2024 01:013,50357,840,65519,924,00011,954,00092,905,472
20May 22, 2024 01:003,51457,105,88119,987,00011,992,00092,897,280
21May 22, 2024 01:013,51461,444,33919,983,00011,990,00093,163,520
22May 22, 2024 01:013,51758,710,24120,001,00012,000,00092,930,048
23May 22, 2024 01:013,51762,798,89521,002,00011,001,00092,930,048
24May 22, 2024 01:003,51957,344,84320,013,00012,007,00092,901,376
25May 22, 2024 01:013,52560,285,16020,048,00012,029,00092,889,088
26May 22, 2024 01:003,52965,455,17720,073,00012,043,00092,913,664
27May 22, 2024 01:013,53761,747,16420,115,00012,069,00092,925,952
28May 22, 2024 01:013,634102,287,87933,068,141094,478,336
29May 22, 2024 01:013,64098,163,63333,122,712094,490,624
30May 22, 2024 01:013,643102,078,57333,146,931094,482,432
31May 22, 2024 01:003,64497,161,10333,163,060094,486,528
32May 22, 2024 01:013,651112,505,74933,228,363094,486,528
33May 22, 2024 01:013,653100,955,36933,238,405094,486,528
34May 22, 2024 01:013,653107,095,68833,245,902094,482,432
35May 22, 2024 01:003,65695,208,17433,266,266094,494,720
36May 22, 2024 01:013,658101,228,80433,291,298094,482,432
37May 22, 2024 01:013,66098,631,17933,304,832094,474,240
38May 22, 2024 01:013,663110,669,22033,333,594094,609,408
39May 22, 2024 01:013,66490,154,07133,344,301094,486,528
40May 22, 2024 01:013,66497,699,11233,340,827094,613,504
41May 22, 2024 01:003,67099,547,10933,398,495094,498,816
42May 22, 2024 01:013,67393,520,10433,419,766094,478,336
43May 22, 2024 01:013,682102,195,52633,502,212094,478,336
44May 22, 2024 01:013,69197,615,76633,592,098094,498,816
45May 22, 2024 01:013,70097,529,53733,672,068094,617,600
46May 22, 2024 01:013,85660,757,91822,054,00013,032,00093,106,176
47May 22, 2024 01:014,05265,777,11120,928,00015,945,00093,179,904
48May 22, 2024 01:014,08663,602,85521,106,00016,081,00093,085,696
49May 22, 2024 01:014,31569,284,55921,142,00018,122,00093,118,464
50May 22, 2024 01:014,79772,789,94622,336,00021,321,00093,089,792
51May 22, 2024 01:005,02575,270,91921,871,00023,859,00093,048,832
52May 22, 2024 01:015,11375,221,51922,253,00024,276,00093,089,792
53May 22, 2024 01:015,72579,278,09022,040,00030,055,00093,003,776
54May 22, 2024 01:015,77381,115,07624,245,00028,286,00093,237,248
55May 22, 2024 01:016,29688,688,40524,125,00033,172,00093,310,976
56May 22, 2024 01:016,55584,209,61126,841,00032,805,00093,294,592
57May 22, 2024 01:016,68488,939,93224,928,00035,896,00093,315,072
58May 22, 2024 01:006,76488,680,99524,218,00037,337,00093,163,520
59May 22, 2024 01:016,89690,354,72924,902,00037,851,00093,216,768
60May 22, 2024 01:007,26592,986,45725,043,00041,071,00093,253,632
61May 22, 2024 01:017,37192,914,84325,029,00042,049,00093,118,464
62May 22, 2024 01:017,38696,685,49625,079,00042,134,00093,200,384
63May 22, 2024 01:007,39697,177,34925,113,00042,190,00093,216,768
64May 22, 2024 01:017,42294,074,56326,211,00041,333,00093,245,440
65May 22, 2024 01:017,42397,259,48325,206,00042,346,00093,265,920
66May 22, 2024 01:017,46096,215,13523,960,00043,927,00093,343,744
67May 22, 2024 01:017,48398,066,88825,036,00043,062,00093,171,712
68May 22, 2024 01:017,51091,399,78225,124,00043,213,00093,204,480
69May 22, 2024 01:017,51994,165,11326,160,00042,259,00093,212,672
70May 22, 2024 01:017,52196,861,04626,168,00042,272,00093,138,944
71May 22, 2024 01:017,56198,607,45226,924,00041,882,00093,220,864
72May 22, 2024 01:017,60396,553,32826,070,00043,117,00093,155,328