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 listApr 22, 2024 14:28Yuriy LyfenkoYuriy LyfenkoScore: 3,615Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 22, 2024 14:283,457554,931,58122,329,0009,134,00092,831,744
2Apr 22, 2024 14:263,460559,822,39422,347,0009,142,00092,938,240
3Apr 22, 2024 14:283,462561,071,13624,394,0007,114,00092,909,568
4Apr 22, 2024 14:283,466555,537,88522,385,0009,157,00092,868,608
5Apr 22, 2024 14:263,466556,772,06124,422,0007,123,00092,884,992
6Apr 22, 2024 14:263,470558,976,09321,708,0009,867,00092,848,128
7Apr 22, 2024 14:283,471556,715,35825,473,0006,113,00092,893,184
8Apr 22, 2024 14:283,474556,281,81322,720,0008,890,00092,958,720
9Apr 22, 2024 14:283,476555,756,73121,748,0009,885,00092,930,048
10Apr 22, 2024 14:263,476560,044,17823,721,0007,907,00092,897,280
11Apr 22, 2024 14:283,478560,464,32721,760,0009,891,00092,942,336
12Apr 22, 2024 14:283,481560,659,80120,787,00010,888,00092,934,144
13Apr 22, 2024 14:283,482558,000,30224,752,0006,930,00092,905,472
14Apr 22, 2024 14:283,482562,458,92025,745,0005,941,00092,917,760
15Apr 22, 2024 14:263,483561,058,92924,759,0006,932,00092,876,800
16Apr 22, 2024 14:283,484556,225,53020,805,00010,898,00092,946,432
17Apr 22, 2024 14:263,485557,680,18922,795,0008,920,00092,864,512
18Apr 22, 2024 14:283,485562,034,64223,782,0007,927,00092,868,608
19Apr 22, 2024 14:283,486561,771,34422,800,0008,921,00093,024,256
20Apr 22, 2024 14:283,489556,957,07420,836,00010,914,00092,884,992
21Apr 22, 2024 14:283,494558,734,58620,866,00010,929,00092,917,760
22Apr 22, 2024 14:283,499557,986,17622,888,0008,956,00092,884,992
23Apr 22, 2024 14:283,504557,536,97722,920,0008,969,00092,921,856
24Apr 22, 2024 14:283,532560,158,51824,109,0008,036,00092,975,104
25Apr 22, 2024 14:283,615589,441,11132,897,001094,605,312
26Apr 22, 2024 14:283,616602,590,37832,908,787094,605,312
27Apr 22, 2024 14:283,621588,581,17032,951,410094,605,312
28Apr 22, 2024 14:283,623592,012,37532,972,315094,609,408
29Apr 22, 2024 14:263,624583,881,42032,982,562094,605,312
30Apr 22, 2024 14:283,626586,009,69633,000,880094,605,312
31Apr 22, 2024 14:263,632602,397,31333,053,508094,724,096
32Apr 22, 2024 14:283,634589,821,17433,068,915094,720,000
33Apr 22, 2024 14:283,636602,094,57033,085,633094,609,408
34Apr 22, 2024 14:263,640615,409,07233,122,869094,605,312
35Apr 22, 2024 14:283,640590,018,79733,128,000094,605,312
36Apr 22, 2024 14:283,641601,881,38233,129,658094,605,312
37Apr 22, 2024 14:284,340570,438,24121,268,00018,230,00093,200,384
38Apr 22, 2024 14:264,605566,715,31229,932,00011,972,00093,184,000
39Apr 22, 2024 14:285,849572,808,84228,122,00025,108,00093,122,560
40Apr 22, 2024 14:266,395578,957,70829,097,00029,097,00093,097,984
41Apr 22, 2024 14:286,426581,097,10530,727,00027,753,00093,097,984
42Apr 22, 2024 14:266,494587,205,49933,053,00026,042,00093,089,792
43Apr 22, 2024 14:286,828595,119,72229,588,00032,547,00093,343,744
44Apr 22, 2024 14:286,877590,654,65028,261,00034,317,00093,069,312
45Apr 22, 2024 14:286,965585,833,68130,182,00033,200,00093,323,264
46Apr 22, 2024 14:286,980593,998,96032,262,00031,253,00093,323,264
47Apr 22, 2024 14:287,157592,126,92328,055,00037,073,00093,057,024
48Apr 22, 2024 14:287,164585,589,96330,089,00035,104,00093,327,360