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 26, 2021 19:31Yuriy LyfenkoYuriy LyfenkoScore: 9,615Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 29, 2021 14:454,66998,814,69642,492,406094,646,272
2May 29, 2021 14:454,68297,360,35542,604,825094,658,560
3May 29, 2021 14:454,687108,902,62542,654,997094,662,656
4May 26, 2021 19:334,689109,710,96342,671,174094,662,656
5May 26, 2021 19:314,692107,663,97642,693,157094,662,656
6May 26, 2021 19:334,693120,888,83042,710,574094,654,464
7May 26, 2021 19:334,733100,168,97643,066,318094,781,440
8May 26, 2021 19:314,759108,834,87543,306,240094,654,464
9May 26, 2021 19:314,851124,821,44944,146,458094,646,272
10May 26, 2021 19:339,573108,090,85473,099,00014,019,00094,670,848
11May 26, 2021 19:339,584113,927,15271,175,00016,039,00094,683,136
12May 29, 2021 14:459,589110,537,14671,213,00016,048,00094,679,040
13May 29, 2021 14:459,592108,147,81172,241,00015,050,00094,552,064
14May 26, 2021 19:319,594113,190,97672,250,00015,052,00094,687,232
15May 29, 2021 14:459,595119,499,73771,261,00016,058,00094,683,136
16May 26, 2021 19:319,595112,174,62471,260,00016,058,00094,687,232
17May 26, 2021 19:319,602116,515,52071,306,00016,069,00094,683,136
18May 26, 2021 19:339,607113,450,13569,337,00018,087,00094,552,064
19May 26, 2021 19:339,615119,525,74570,401,00017,097,00094,547,968
20May 26, 2021 19:339,619113,959,51968,636,00018,899,00094,547,968
21May 29, 2021 14:459,623115,573,74173,641,00013,932,00094,683,136
22May 26, 2021 19:339,624114,773,55865,684,00021,894,00093,110,272
23May 29, 2021 14:459,624113,365,83670,468,00017,113,00094,552,064
24May 26, 2021 19:339,627115,936,27373,668,00013,937,00094,547,968
25May 29, 2021 14:459,631116,774,21370,710,00016,930,00094,674,944
26May 26, 2021 19:319,631114,927,63068,723,00018,923,00094,547,968
27May 29, 2021 14:459,636116,204,08569,752,00017,936,00094,547,968
28May 26, 2021 19:319,638113,617,29769,765,00017,939,00094,547,968
29May 26, 2021 19:319,647115,026,67868,837,00018,955,00094,552,064
30May 29, 2021 14:459,739111,768,03467,712,00020,911,00092,979,200
31May 26, 2021 19:319,740116,215,48666,728,00021,910,00093,106,176
32May 26, 2021 19:319,780110,144,49172,001,00017,000,00092,983,296
33May 26, 2021 19:339,809108,168,18371,211,00018,053,00092,962,816
34May 26, 2021 19:319,970117,743,49468,794,00021,934,00093,245,440
35May 29, 2021 14:459,989114,576,43369,921,00020,976,00093,241,344
36May 26, 2021 19:3310,000112,391,11572,999,00017,999,00093,245,440