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:03Joad NacerJoad NacerScore: 3,681Success
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:043,38656,418,96119,878,00010,933,00093,171,712
2May 22, 2024 00:043,42160,673,54720,084,00011,046,00092,897,280
3May 22, 2024 00:033,43654,666,36720,174,00011,095,00092,938,240
4May 22, 2024 00:043,43650,752,84320,174,00011,095,00092,942,336
5May 22, 2024 00:043,43954,857,26820,188,00011,103,00092,958,720
6May 22, 2024 00:043,44155,290,46020,204,00011,112,00092,901,376
7May 22, 2024 00:043,47559,441,17020,399,00011,219,00093,151,232
8May 22, 2024 00:033,49256,939,93220,854,00010,923,00093,179,904
9May 22, 2024 00:043,49656,230,45920,880,00010,937,00092,950,528
10May 22, 2024 00:043,49956,604,03320,896,00010,945,00092,868,608
11May 22, 2024 00:023,50355,739,43219,925,00011,955,00092,889,088
12May 22, 2024 00:043,51458,456,86319,983,00011,990,00093,118,464
13May 22, 2024 00:043,52159,805,94020,027,00012,016,00093,081,600
14May 22, 2024 00:043,52259,141,69820,033,00012,020,00092,938,240
15May 22, 2024 00:043,52761,165,49520,062,00012,037,00092,913,664
16May 22, 2024 00:023,52953,810,33020,070,00012,042,00092,925,952
17May 22, 2024 00:033,53159,602,16120,084,00012,050,00092,954,624
18May 22, 2024 00:023,53459,735,70320,099,00012,059,00092,884,992
19May 22, 2024 00:043,63892,053,70733,106,107094,486,528
20May 22, 2024 00:023,65197,521,78633,227,565094,486,528
21May 22, 2024 00:023,65595,375,47533,263,306094,478,336
22May 22, 2024 00:033,656116,927,14333,268,114094,621,696
23May 22, 2024 00:043,658110,583,07033,286,890094,490,624
24May 22, 2024 00:043,658110,942,45733,291,646094,486,528
25May 22, 2024 00:043,65996,518,60433,296,391094,482,432
26May 22, 2024 00:043,661111,494,23033,318,309094,482,432
27May 22, 2024 00:023,66497,431,56833,337,922094,498,816
28May 22, 2024 00:033,66596,121,04233,351,120094,486,528
29May 22, 2024 00:033,668105,713,49433,376,988094,748,672
30May 22, 2024 00:043,67398,120,44833,421,956094,490,624
31May 22, 2024 00:043,681104,345,40233,499,913094,478,336
32May 22, 2024 00:043,690103,013,98733,574,989094,625,792
33May 22, 2024 00:043,702110,389,45733,691,386094,744,576
34May 22, 2024 00:043,88556,621,98221,214,00014,143,00093,089,792
35May 22, 2024 00:044,10063,179,77121,178,00016,136,00093,163,520
36May 22, 2024 00:044,21371,210,63221,186,00017,151,00093,106,176
37May 22, 2024 00:044,43969,760,37321,209,00019,189,00093,102,080
38May 22, 2024 00:024,47766,143,16720,866,00019,872,00093,138,944
39May 22, 2024 00:024,58270,457,23121,357,00020,340,00093,126,656
40May 22, 2024 00:045,17374,647,16623,037,00024,039,00093,204,480
41May 22, 2024 00:035,32474,321,71224,225,00024,225,00093,003,776
42May 22, 2024 00:025,34974,443,35422,848,00025,829,00093,085,696
43May 22, 2024 00:035,35973,729,88921,895,00026,871,00093,097,984
44May 22, 2024 00:045,46874,634,29622,888,00026,868,00093,097,984
45May 22, 2024 00:047,42394,862,22325,205,00042,345,00093,188,096
46May 22, 2024 00:037,47692,655,64425,011,00043,019,00093,245,440
47May 22, 2024 00:047,50994,981,32125,121,00043,208,00093,306,880
48May 22, 2024 00:027,52192,140,54425,162,00043,278,00093,167,616
49May 22, 2024 00:037,52292,550,19225,165,00043,285,00093,196,288
50May 22, 2024 00:027,52795,091,06625,184,00043,316,00093,224,960
51May 22, 2024 00:027,54595,125,36725,243,00043,418,00093,249,536
52May 22, 2024 00:047,56298,636,82826,926,00041,884,00093,216,768
53May 22, 2024 00:047,56497,704,44824,940,00043,895,00093,294,592
54May 22, 2024 00:047,56497,770,48124,938,00043,891,00093,253,632
55May 22, 2024 00:037,573104,456,14525,969,00042,949,00093,196,288
56May 22, 2024 00:047,57999,139,94525,988,00042,980,00093,192,192
57May 22, 2024 00:047,58693,393,74725,013,00044,023,00093,212,672
58May 22, 2024 00:047,60297,503,45025,064,00044,113,00093,204,480
59May 22, 2024 00:047,61194,023,36825,094,00044,166,00093,270,016
60May 22, 2024 00:037,69695,367,94825,013,00045,024,00093,134,848