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 11:25Joad NacerJoad NacerScore: 3,665Success
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 11:243,45856,478,08721,316,00010,150,00092,897,280
2May 22, 2024 11:243,46461,227,61321,351,00010,167,00092,876,800
3May 22, 2024 11:243,48458,168,39020,806,00010,898,00092,864,512
4May 22, 2024 11:253,49265,214,06720,851,00010,922,00092,950,528
5May 22, 2024 11:253,49258,685,73522,839,0008,937,00092,909,568
6May 22, 2024 11:253,49257,716,25519,860,00011,916,00093,143,040
7May 22, 2024 11:243,49264,423,17921,847,0009,930,00092,897,280
8May 22, 2024 11:253,49456,740,82221,541,00010,257,00092,856,320
9May 22, 2024 11:253,51561,864,19019,994,00011,996,00092,868,608
10May 22, 2024 11:243,52857,735,62620,068,00012,041,00092,995,584
11May 22, 2024 11:253,53854,764,17521,127,00011,066,00092,905,472
12May 22, 2024 11:243,54156,665,90720,138,00012,082,00092,901,376
13May 22, 2024 11:253,55659,085,08822,246,00010,112,00092,917,760
14May 22, 2024 11:253,55659,522,51821,234,00011,122,00092,938,240
15May 22, 2024 11:253,56558,563,85622,304,00010,138,00092,909,568
16May 22, 2024 11:253,65596,486,82433,264,136094,748,672
17May 22, 2024 11:253,66095,726,99533,307,979094,502,912
18May 22, 2024 11:243,66094,868,32333,302,648094,490,624
19May 22, 2024 11:243,66589,799,07733,350,035094,490,624
20May 22, 2024 11:253,66787,687,65033,369,910094,482,432
21May 22, 2024 11:253,672101,547,26933,414,657094,752,768
22May 22, 2024 11:253,68790,064,96433,549,688094,490,624
23May 22, 2024 11:253,701111,624,58833,680,259094,486,528
24May 22, 2024 11:243,70896,949,48333,738,339094,482,432
25May 22, 2024 11:253,88262,392,99322,203,00013,120,00093,138,944
26May 22, 2024 11:254,79677,587,86022,330,00021,315,00093,081,600
27May 22, 2024 11:255,19473,903,22924,134,00023,129,00093,077,504
28May 22, 2024 11:255,97879,271,39425,183,00029,213,00092,983,296
29May 22, 2024 11:246,12279,145,29322,882,00032,831,00093,134,848
30May 22, 2024 11:256,96490,033,51224,141,00039,230,00093,327,360
31May 22, 2024 11:247,13891,513,38623,985,00040,974,00093,134,848
32May 22, 2024 11:247,24197,678,99923,961,00041,931,00093,241,344
33May 22, 2024 11:257,50599,517,28426,113,00042,183,00093,331,456
34May 22, 2024 11:257,52194,143,60525,161,00043,278,00093,196,288
35May 22, 2024 11:257,562100,204,83224,934,00043,884,00093,265,920
36May 22, 2024 11:257,60990,399,88024,085,00045,159,00093,233,152