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:50Joad NacerJoad NacerScore: 3,668Success
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:503,42159,208,66520,083,00011,045,00092,884,992
2May 22, 2024 01:503,42954,925,36521,138,00010,065,00092,921,856
3May 22, 2024 01:503,43558,261,93820,168,00011,092,00092,901,376
4May 22, 2024 01:503,43659,431,83920,173,00011,095,00092,962,816
5May 22, 2024 01:503,43757,206,49820,177,00011,097,00092,889,088
6May 22, 2024 01:513,44454,647,41720,217,00011,119,00092,893,184
7May 22, 2024 01:503,44558,641,75520,224,00011,123,00092,864,512
8May 22, 2024 01:503,44956,164,52320,247,00011,136,00092,852,224
9May 22, 2024 01:513,45659,518,89522,322,0009,131,00092,901,376
10May 22, 2024 01:503,46456,885,08821,351,00010,167,00092,893,184
11May 22, 2024 01:503,46758,711,30422,391,0009,160,00092,839,936
12May 22, 2024 01:503,49062,376,88519,852,00011,911,00092,962,816
13May 22, 2024 01:503,49256,321,41519,860,00011,916,00092,889,088
14May 22, 2024 01:513,49559,873,55719,878,00011,927,00092,950,528
15May 22, 2024 01:503,49657,568,00019,884,00011,930,00092,925,952
16May 22, 2024 01:503,49958,734,38620,895,00010,945,00092,884,992
17May 22, 2024 01:503,50659,370,17919,942,00011,965,00092,917,760
18May 22, 2024 01:503,50659,805,96419,943,00011,966,00092,946,432
19May 22, 2024 01:503,51557,680,76219,990,00011,994,00092,917,760
20May 22, 2024 01:503,51757,674,46320,004,00012,002,00093,167,616
21May 22, 2024 01:503,51757,507,28620,005,00012,003,00092,884,992
22May 22, 2024 01:503,51961,620,47421,018,00011,009,00092,954,624
23May 22, 2024 01:513,52259,659,11420,033,00012,020,00092,925,952
24May 22, 2024 01:503,52462,215,57520,041,00012,025,00092,889,088
25May 22, 2024 01:503,52456,875,09020,041,00012,024,00092,901,376
26May 22, 2024 01:503,52557,427,20320,046,00012,028,00092,897,280
27May 22, 2024 01:503,64497,409,07933,161,919094,482,432
28May 22, 2024 01:503,648103,665,31033,198,993094,482,432
29May 22, 2024 01:513,64897,325,10733,200,653094,744,576
30May 22, 2024 01:513,65296,917,83233,229,111094,482,432
31May 22, 2024 01:503,65497,425,38333,248,314094,486,528
32May 22, 2024 01:513,65591,075,99033,263,244094,494,720
33May 22, 2024 01:503,66099,475,56333,304,831094,478,336
34May 22, 2024 01:503,660103,923,08133,310,334094,621,696
35May 22, 2024 01:503,66199,454,36633,314,979094,490,624
36May 22, 2024 01:503,664106,919,23933,342,339094,486,528
37May 22, 2024 01:503,66898,552,36733,379,717094,482,432
38May 22, 2024 01:503,66894,669,29933,380,897094,486,528
39May 22, 2024 01:503,67296,547,81133,411,038094,482,432
40May 22, 2024 01:503,67297,017,87533,416,090094,494,720
41May 22, 2024 01:503,67397,610,28333,421,962094,494,720
42May 22, 2024 01:503,676101,533,16433,454,888094,613,504
43May 22, 2024 01:503,68580,391,54233,533,123094,617,600
44May 22, 2024 01:503,68795,015,08433,553,915094,482,432
45May 22, 2024 01:504,07665,953,53121,052,00016,039,00093,163,520
46May 22, 2024 01:504,25670,897,76722,840,00015,889,00093,081,600
47May 22, 2024 01:514,40968,246,83521,066,00019,059,00093,114,368
48May 22, 2024 01:514,43564,627,80921,187,00019,169,00093,147,136
49May 22, 2024 01:504,60664,266,09122,953,00018,961,00093,134,848
50May 22, 2024 01:504,64868,269,07122,154,00020,140,00093,102,080
51May 22, 2024 01:504,77868,743,73121,236,00022,247,00093,106,176
52May 22, 2024 01:504,78469,481,23321,259,00022,271,00093,093,888
53May 22, 2024 01:505,44974,823,42421,819,00027,769,00093,081,600
54May 22, 2024 01:505,89878,741,15123,290,00030,379,00093,020,160
55May 22, 2024 01:506,03979,584,03222,980,00031,972,00093,372,416
56May 22, 2024 01:506,44885,143,87324,281,00034,398,00093,286,400
57May 22, 2024 01:506,57287,567,12724,919,00034,886,00093,085,696
58May 22, 2024 01:506,59491,346,81724,003,00036,005,00093,294,592
59May 22, 2024 01:506,60483,723,46824,040,00036,060,00093,175,808
60May 22, 2024 01:506,73987,632,10523,124,00038,205,00093,249,536
61May 22, 2024 01:506,78487,095,36524,894,00036,843,00093,323,264
62May 22, 2024 01:507,34494,573,84023,938,00042,889,00093,364,224
63May 22, 2024 01:507,38490,283,61825,072,00042,121,00093,171,712
64May 22, 2024 01:507,39590,721,86626,114,00041,179,00093,200,384
65May 22, 2024 01:517,41893,942,77526,195,00041,308,00093,118,464
66May 22, 2024 01:517,44995,790,41624,922,00042,866,00093,143,040
67May 22, 2024 01:507,46997,497,26923,989,00043,979,00093,220,864
68May 22, 2024 01:507,47295,886,59723,998,00043,997,00093,351,936
69May 22, 2024 01:507,48395,976,40624,035,00044,064,00093,147,136
70May 22, 2024 01:517,48695,983,99726,048,00042,078,00093,200,384
71May 22, 2024 01:507,48798,255,30825,049,00043,085,00093,257,728
72May 22, 2024 01:507,52092,618,58924,151,00044,277,00093,114,368