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 listAug 31, 2024 08:10AnSaAnSaScore: 4,224Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 31, 2024 08:10458,767,52319,94312,96397,214,464
2Aug 31, 2024 08:10456,110,14318,97913,98497,243,136
3Aug 31, 2024 08:10456,973,45919,16414,12097,443,840
4Sep 3, 2024 15:053,60458,688,24718,884,00013,914,00097,214,464
5Sep 3, 2024 15:053,61062,169,34819,908,00012,940,00097,210,368
6Sep 3, 2024 15:053,61259,422,17017,931,00014,942,00097,218,560
7Sep 3, 2024 15:053,61765,188,55016,958,00015,960,00097,198,080
8Sep 3, 2024 15:053,62258,414,59018,976,00013,982,00097,239,040
9Sep 3, 2024 15:053,62257,681,09921,975,00010,987,00097,193,984
10Sep 3, 2024 15:053,62259,847,26719,974,00012,983,00097,296,384
11Sep 3, 2024 15:053,62562,887,17317,991,00014,992,00097,173,504
12Jun 24, 2024 18:413,63060,463,75019,017,00014,012,00097,198,080
13Aug 31, 2024 08:103,63158,579,39417,020,00016,019,00097,185,792
14Jun 24, 2024 18:413,63258,848,49719,032,00014,023,00097,300,480
15Sep 3, 2024 15:053,63357,419,25217,032,00016,030,00097,234,944
16Jun 24, 2024 18:413,63563,707,65719,044,00014,032,00097,165,312
17Jun 25, 2024 14:403,64260,088,74319,080,00014,059,00097,267,712
18Aug 31, 2024 08:103,64766,463,97419,108,00014,080,00097,284,096
19Sep 3, 2024 15:053,64960,428,50719,121,00014,089,00097,193,984
20Sep 3, 2024 15:053,66062,457,56320,187,00013,121,00097,218,560
21Aug 31, 2024 08:103,66455,853,25222,231,00011,115,00097,206,272
22Jun 25, 2024 14:403,66658,081,01719,210,00014,155,00097,206,272
23Jun 25, 2024 14:403,72064,048,69516,928,00016,928,00097,431,552
24Aug 31, 2024 08:103,72362,492,80819,927,00013,949,00097,210,368
25Aug 31, 2024 08:104,04063,169,11420,868,00015,899,00097,234,944
26Jun 24, 2024 18:414,07660,957,34319,049,00018,046,00097,452,032
27Aug 31, 2024 08:104,10773,771,80521,212,00016,161,00097,226,752
28Jun 24, 2024 18:414,12968,196,25221,328,00016,250,00097,472,512
29Sep 3, 2024 15:054,22467,225,58118,209,00020,232,00097,443,840
30Jun 24, 2024 18:414,23169,899,66020,264,00018,237,00097,439,744
31Jun 24, 2024 18:414,348111,313,83439,569,217098,807,808
32Jun 24, 2024 18:414,360103,424,22139,678,434098,807,808
33Jun 25, 2024 14:404,367110,808,49039,739,443098,803,712
34Jun 25, 2024 14:404,37998,681,21939,847,221098,803,712
35Jun 25, 2024 14:404,386104,141,39639,915,119098,807,808
36Jun 24, 2024 18:414,388106,425,65039,930,754098,799,616
37Sep 3, 2024 15:054,76472,561,95722,178,00021,170,00097,456,128
38Jun 25, 2024 14:406,56485,706,39825,882,00033,846,00097,382,400
39Aug 31, 2024 08:106,79894,727,94522,948,00038,912,00097,382,400
40Sep 3, 2024 15:056,90887,769,94519,957,00042,908,00097,632,256
41Jun 25, 2024 14:407,03090,320,41926,989,00036,985,00097,361,920
42Sep 3, 2024 15:057,29289,819,52124,131,00042,230,00097,611,776
43Aug 31, 2024 08:107,77496,572,06716,939,00053,808,00097,583,104
44Jun 25, 2024 14:407,92498,233,93432,049,00040,061,00097,566,720
45Aug 31, 2024 08:108,16998,731,52526,119,00048,221,00097,546,240
46Sep 3, 2024 15:058,331107,156,61926,933,00048,880,00097,783,808
47Jun 24, 2024 18:418,389105,624,73032,142,00044,195,00097,538,048
48Jun 24, 2024 18:418,417101,304,11328,218,00048,373,00097,558,528
49Sep 3, 2024 15:058,433101,900,31631,892,00044,848,00097,587,200
50Jun 24, 2024 18:418,453102,095,22031,967,00044,954,00097,529,856
51Aug 31, 2024 08:108,548113,142,72024,931,00052,855,00097,677,312
52Jun 25, 2024 14:408,609103,300,72831,137,00047,208,00097,763,328
53Sep 3, 2024 15:058,691109,727,54833,035,00046,049,00097,775,616
54Jun 25, 2024 14:408,694107,096,48830,044,00049,072,00097,517,568
55Aug 31, 2024 08:108,702105,274,95331,075,00048,116,00097,546,240
56Aug 31, 2024 08:108,747107,079,46325,190,00054,412,00097,718,272
57Jun 25, 2024 14:409,201115,945,16325,917,00057,815,00097,681,408