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 listOct 31, 2021 13:57Ilya AniskovetsIlya AniskovetsScore: 9,810Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Oct 31, 2021 13:459,311143,364,77684,730,665094,728,192
2Oct 31, 2021 13:579,314136,363,53584,759,700094,789,632
3Oct 31, 2021 13:459,324152,065,54484,852,481094,769,152
4Oct 31, 2021 14:119,346142,491,49185,052,359094,679,040
5Oct 31, 2021 14:119,348148,265,03885,067,810094,715,904
6Oct 31, 2021 13:459,350190,651,69185,087,984094,732,288
7Oct 31, 2021 13:579,351151,893,35485,091,537094,760,960
8Oct 31, 2021 13:579,373135,904,94585,292,684094,720,000
9Oct 31, 2021 14:119,390151,261,31285,445,847094,744,576
10Oct 31, 2021 13:579,769111,903,18938,956,00049,944,00094,584,832
11Oct 31, 2021 14:119,789116,702,62336,033,00053,048,00094,601,216
12Oct 31, 2021 13:459,796110,606,89039,065,00050,083,00094,572,544
13Oct 31, 2021 13:579,800111,257,43243,087,00046,093,00094,756,864
14Oct 31, 2021 13:459,804114,632,97745,109,00044,106,00094,789,632
15Oct 31, 2021 14:119,806111,850,75234,090,00055,146,00094,756,864
16Oct 31, 2021 14:119,806113,517,20439,101,00050,130,00094,638,080
17Oct 31, 2021 14:119,809108,631,50245,131,00044,128,00093,011,968
18Oct 31, 2021 13:459,810111,127,86747,143,00042,128,00094,773,248
19Oct 31, 2021 13:459,810112,783,17541,124,00048,145,00094,789,632
20Oct 31, 2021 13:579,816113,531,15542,154,00047,173,00094,789,632
21Oct 31, 2021 13:459,818113,505,38144,168,00045,172,00094,773,248
22Oct 31, 2021 13:579,820116,937,15639,158,00050,202,00093,020,160
23Oct 31, 2021 13:459,821109,200,08642,173,00047,194,00094,580,736
24Oct 31, 2021 14:119,825118,840,34839,177,00050,227,00094,572,544
25Oct 31, 2021 13:579,827119,234,28743,208,00046,222,00094,789,632
26Oct 31, 2021 13:579,830119,509,12839,200,00050,257,00094,654,464
27Oct 31, 2021 13:459,832120,571,98945,238,00044,232,00094,556,160
28Oct 31, 2021 14:119,835115,272,66045,250,00044,244,00094,547,968
29Oct 31, 2021 13:459,835115,164,73039,218,00050,279,00094,789,632
30Oct 31, 2021 13:579,849121,512,77143,819,00045,811,00094,773,248
31Oct 31, 2021 13:579,861119,473,77644,868,00044,868,00094,736,384
32Oct 31, 2021 14:119,906116,135,96545,073,00045,073,00094,547,968
33Oct 31, 2021 13:579,984112,942,06346,925,00043,930,00092,962,816
34Oct 31, 2021 14:1110,071117,833,23544,828,00046,821,00092,987,392
35Oct 31, 2021 13:4510,112117,580,11440,008,00052,011,00093,245,440
36Oct 31, 2021 14:1110,469127,770,56845,129,00050,143,00093,302,784