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:15Joad NacerJoad NacerScore: 3,672Success
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:213,44252,914,09620,205,00011,113,00092,942,336
2May 22, 2024 01:153,44853,965,30620,242,00011,133,00092,876,800
3May 22, 2024 01:163,45162,220,51721,272,00010,129,00092,884,992
4May 22, 2024 01:213,48559,264,39820,810,00010,900,00092,872,704
5May 22, 2024 01:163,51257,311,83121,972,0009,987,00092,925,952
6May 22, 2024 01:163,51457,841,99320,986,00010,992,00092,987,392
7May 22, 2024 01:153,51456,429,04519,988,00011,992,00092,917,760
8May 22, 2024 01:213,52058,276,43720,022,00012,013,00093,110,272
9May 22, 2024 01:163,52256,072,36320,032,00012,019,00092,917,760
10May 22, 2024 01:163,52357,737,67220,038,00012,023,00092,893,184
11May 22, 2024 01:213,52955,390,03620,069,00012,041,00092,905,472
12May 22, 2024 01:213,53058,864,78920,079,00012,047,00092,905,472
13May 22, 2024 01:163,53854,328,51420,120,00012,072,00092,844,032
14May 22, 2024 01:163,54058,220,61220,133,00012,080,00092,942,336
15May 22, 2024 01:163,54362,190,83920,151,00012,090,00092,934,144
16May 22, 2024 01:153,55853,929,04621,250,00011,131,00092,946,432
17May 22, 2024 01:213,64294,508,56333,137,904094,625,792
18May 22, 2024 01:163,64697,840,76033,175,700094,482,432
19May 22, 2024 01:213,64894,729,22233,198,805094,482,432
20May 22, 2024 01:163,657100,743,06133,278,177094,486,528
21May 22, 2024 01:163,659109,412,68733,299,028094,486,528
22May 22, 2024 01:153,65998,740,90833,300,147094,486,528
23May 22, 2024 01:153,66593,191,70933,348,171094,482,432
24May 22, 2024 01:153,66688,028,69733,356,706094,490,624
25May 22, 2024 01:163,672110,966,98433,414,781094,490,624
26May 22, 2024 01:163,67292,225,72333,413,173094,490,624
27May 22, 2024 01:163,67595,266,12333,440,409094,486,528
28May 22, 2024 01:213,68487,596,70933,526,320094,498,816
29May 22, 2024 01:153,82362,286,52020,875,00013,916,00093,130,752
30May 22, 2024 01:164,33163,132,09821,220,00018,189,00093,130,752
31May 22, 2024 01:214,40270,756,98623,032,00017,024,00093,167,616
32May 22, 2024 01:164,66966,861,52522,254,00020,231,00093,044,736
33May 22, 2024 01:165,18572,045,84523,088,00024,092,00093,114,368
34May 22, 2024 01:155,61888,831,10022,053,00029,070,00093,126,656
35May 22, 2024 01:155,96178,469,18523,103,00031,138,00093,073,408
36May 22, 2024 01:166,65291,074,97324,213,00036,320,00093,298,688
37May 22, 2024 01:166,90691,311,85124,937,00037,904,00093,151,232
38May 22, 2024 01:166,90987,381,10425,946,00036,923,00093,216,768
39May 22, 2024 01:216,98892,025,50624,225,00039,365,00093,097,984
40May 22, 2024 01:157,39392,634,14126,106,00041,168,00093,298,688
41May 22, 2024 01:167,45497,756,67924,937,00042,892,00093,163,520
42May 22, 2024 01:157,46995,417,09423,988,00043,978,00093,253,632
43May 22, 2024 01:167,51992,864,80725,156,00043,268,00093,245,440
44May 22, 2024 01:157,542101,305,47525,232,00043,400,00093,257,728
45May 22, 2024 01:167,56896,463,35225,318,00043,547,00093,171,712
46May 22, 2024 01:167,57096,592,35725,958,00042,931,00093,192,192
47May 22, 2024 01:217,58294,095,58324,997,00043,995,00093,175,808
48May 22, 2024 01:217,597101,033,04427,053,00042,083,00093,241,344