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:05Joad NacerJoad NacerScore: 3,648Success
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:053,41256,727,80920,034,00011,018,00093,138,944
2May 22, 2024 01:053,42758,410,53820,119,00011,065,00092,864,512
3May 22, 2024 01:043,42757,986,25920,123,00011,067,00092,897,280
4May 22, 2024 01:053,43558,295,50621,177,00010,084,00092,893,184
5May 22, 2024 01:053,44056,208,87220,196,00011,107,00092,946,432
6May 22, 2024 01:043,44053,978,97720,194,00011,106,00092,921,856
7May 22, 2024 01:053,46958,504,51519,731,00011,838,00092,979,200
8May 22, 2024 01:053,47560,284,84721,423,00010,201,00092,909,568
9May 22, 2024 01:053,49657,650,10820,879,00010,937,00092,913,664
10May 22, 2024 01:043,50458,767,06920,928,00010,962,00092,884,992
11May 22, 2024 01:053,50556,854,42420,934,00010,965,00093,192,192
12May 22, 2024 01:043,50860,558,94819,950,00011,970,00092,876,800
13May 22, 2024 01:043,51157,338,12219,968,00011,980,00092,844,032
14May 22, 2024 01:053,51857,717,09920,008,00012,005,00092,852,224
15May 22, 2024 01:053,52556,888,50720,047,00012,028,00092,925,952
16May 22, 2024 01:053,52556,140,46920,049,00012,029,00092,934,144
17May 22, 2024 01:053,52954,999,98620,071,00012,042,00092,913,664
18May 22, 2024 01:053,53260,635,41021,090,00011,047,00093,200,384
19May 22, 2024 01:053,53360,216,49320,096,00012,058,00092,905,472
20May 22, 2024 01:053,54353,853,32620,151,00012,090,00092,868,608
21May 22, 2024 01:053,59057,654,33221,782,00010,891,00093,097,984
22May 22, 2024 01:053,641104,313,58233,132,389094,494,720
23May 22, 2024 01:043,64594,913,25733,169,220094,494,720
24May 22, 2024 01:053,64892,254,60333,199,178094,740,480
25May 22, 2024 01:053,64890,060,69133,198,049094,494,720
26May 22, 2024 01:053,649106,305,37933,203,270094,486,528
27May 22, 2024 01:053,660102,288,12533,307,780094,490,624
28May 22, 2024 01:043,662100,305,52933,321,086094,478,336
29May 22, 2024 01:053,663100,184,07033,334,286094,613,504
30May 22, 2024 01:053,66795,589,50133,367,559094,490,624
31May 22, 2024 01:053,66998,954,44933,389,853094,629,888
32May 22, 2024 01:043,68192,009,20333,494,385094,482,432
33May 22, 2024 01:053,68594,418,68133,530,454094,494,720
34May 22, 2024 01:054,28365,124,97520,986,00017,988,00093,122,560
35May 22, 2024 01:045,45280,890,47124,301,00025,313,00093,167,616
36May 22, 2024 01:055,50575,955,27922,041,00028,053,00093,126,656
37May 22, 2024 01:045,55676,220,04523,257,00027,302,00093,069,312
38May 22, 2024 01:055,73177,483,29523,068,00029,085,00093,073,408
39May 22, 2024 01:055,99380,183,89523,227,00031,306,00093,069,312
40May 22, 2024 01:056,23982,018,86823,904,00032,868,00093,089,792
41May 22, 2024 01:046,66087,382,27823,234,00037,376,00093,286,400
42May 22, 2024 01:057,02094,585,90623,954,00039,924,00093,175,808
43May 22, 2024 01:057,47194,996,78524,995,00042,992,00093,315,072
44May 22, 2024 01:057,51395,985,71325,135,00043,233,00093,204,480
45May 22, 2024 01:057,52492,392,73325,172,00043,296,00093,249,536
46May 22, 2024 01:057,53699,420,56625,211,00043,364,00093,233,152
47May 22, 2024 01:057,55795,358,18224,917,00043,854,00093,274,112
48May 22, 2024 01:047,57896,256,45223,986,00044,974,00093,356,032