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 listSep 3, 2024 19:20Yuriy LyfenkoYuriy LyfenkoScore: 3,062Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 3, 2024 19:203,031653,625,00720,158,0007,426,00092,921,856
2Aug 31, 2024 21:423,032657,412,03719,419,0008,176,00093,184,000
3Sep 3, 2024 19:203,035656,030,24918,742,0008,878,00093,200,384
4Sep 3, 2024 19:203,039654,802,09518,768,0008,890,00092,897,280
5Sep 3, 2024 19:203,039659,002,99519,458,0008,193,00093,143,040
6Sep 3, 2024 19:203,040657,663,47518,441,0009,220,00092,938,240
7Aug 31, 2024 21:423,040650,806,49318,773,0008,892,00092,905,472
8Sep 3, 2024 19:203,040656,354,19117,787,0009,881,00093,151,232
9Sep 3, 2024 19:203,041653,360,62818,778,0008,895,00093,155,328
10Dec 12, 2024 18:163,044656,003,83618,799,0008,905,00093,069,312
11Dec 12, 2024 18:163,045655,570,37617,816,0009,898,00093,184,000
12Sep 3, 2024 19:203,045649,298,05420,524,0007,183,00092,942,336
13Aug 31, 2024 21:423,045654,940,98218,473,0009,236,00092,880,896
14Aug 31, 2024 21:423,045651,685,33618,801,0008,905,00093,057,024
15Dec 12, 2024 18:163,047653,894,12718,484,0009,242,00092,852,224
16Sep 3, 2024 19:203,047652,377,28519,511,0008,215,00093,155,328
17Aug 31, 2024 21:423,047654,798,32318,818,0008,913,00093,126,656
18Dec 12, 2024 18:163,047657,776,85419,808,0007,923,00093,143,040
19Sep 3, 2024 19:203,048652,237,57719,516,0008,217,00092,921,856
20Sep 3, 2024 19:203,048651,542,52519,519,0008,218,00092,893,184
21Sep 3, 2024 19:203,049654,047,89319,525,0008,221,00092,905,472
22Sep 3, 2024 19:193,049656,145,29719,817,0007,927,00093,200,384
23Sep 3, 2024 19:203,050652,369,32719,822,0007,929,00093,151,232
24Sep 3, 2024 19:203,050658,196,23019,825,0007,930,00093,163,520
25Sep 3, 2024 19:203,050655,436,17719,532,0008,224,00092,917,760
26Sep 3, 2024 19:193,051654,882,47118,842,0008,925,00092,872,704
27Aug 31, 2024 21:423,051652,763,37218,839,0008,923,00093,224,960
28Dec 12, 2024 18:163,052652,436,09921,821,0005,951,00093,208,576
29Dec 12, 2024 18:163,052656,188,44618,844,0008,926,00093,073,408
30Sep 3, 2024 19:203,052654,385,41621,604,0006,172,00092,913,664
31Sep 3, 2024 19:203,053654,735,29819,552,0008,232,00093,143,040
32Sep 3, 2024 19:193,053663,185,06618,851,0008,929,00093,179,904
33Dec 12, 2024 18:163,054656,989,63819,853,0007,941,00093,167,616
34Sep 3, 2024 19:193,054655,635,26420,589,0007,206,00093,130,752
35Sep 3, 2024 19:203,056663,914,78817,880,0009,933,00093,122,560
36Sep 3, 2024 19:193,056652,600,55116,885,00010,926,00093,143,040
37Aug 31, 2024 21:423,057655,630,94917,518,00010,305,00092,913,664
38Aug 31, 2024 21:423,058651,298,58221,867,0005,963,00092,913,664
39Aug 31, 2024 21:423,059653,024,62117,898,0009,943,00092,913,664
40Sep 3, 2024 19:203,060651,315,71416,906,00010,939,00093,151,232
41Sep 3, 2024 19:193,060655,419,71616,909,00010,941,00093,212,672
42Dec 12, 2024 18:163,061658,330,91916,912,00010,943,00093,061,120
43Sep 3, 2024 19:203,061660,550,38716,910,00010,942,00093,151,232
44Sep 3, 2024 19:203,062656,086,31219,606,0008,255,00093,085,696
45Aug 31, 2024 21:423,065660,440,61216,937,00010,959,00093,163,520
46Dec 12, 2024 18:163,067650,836,44616,943,00010,963,00093,134,848
47Sep 3, 2024 19:203,069652,856,35616,957,00010,972,00093,126,656
48Sep 3, 2024 19:203,173650,694,60819,594,0009,281,00092,971,008
49Sep 3, 2024 19:203,201653,097,29219,087,00010,046,00093,229,056
50Sep 3, 2024 19:203,489657,887,58119,844,00011,906,00092,958,720
51Aug 31, 2024 21:423,546653,719,76721,858,00010,408,00092,950,528
52Aug 31, 2024 21:423,822661,840,57921,860,00012,917,00093,200,384
53Aug 31, 2024 21:424,313661,856,83520,127,00019,121,00093,175,808
54Sep 3, 2024 19:204,404662,276,19523,044,00017,033,00093,175,808
55Sep 3, 2024 19:204,412664,233,42527,793,00012,352,00093,081,600
56Sep 3, 2024 19:194,733667,998,49126,044,00017,028,00093,159,424
57Sep 3, 2024 19:194,744664,912,76017,068,00026,105,00093,159,424
58Sep 3, 2024 19:194,817673,634,83721,408,00022,427,00093,155,328
59Aug 31, 2024 21:425,385674,393,55822,462,00026,546,00093,020,160
60Sep 3, 2024 19:205,595679,535,84422,961,00027,953,00093,118,464
61Sep 3, 2024 19:205,752678,614,86529,193,00023,153,00093,110,272
62Sep 3, 2024 19:205,910678,049,22721,911,00031,871,00093,102,080
63Aug 31, 2024 21:426,031675,110,71726,943,00027,940,00093,097,984
64Aug 31, 2024 21:426,381679,669,26823,026,00035,040,00093,077,504
65Aug 31, 2024 21:426,474679,022,02822,345,00036,566,00093,335,552
66Sep 3, 2024 19:206,496680,750,78023,442,00035,673,00093,335,552
67Sep 3, 2024 19:206,573684,324,17225,346,00034,471,00093,331,456
68Sep 3, 2024 19:206,650686,878,06629,247,00031,264,00093,327,360
69Aug 31, 2024 21:426,666685,524,85625,703,00034,957,00093,327,360
70Sep 3, 2024 19:206,673687,695,85227,874,00032,851,00093,323,264
71Sep 3, 2024 19:206,695685,334,19822,972,00037,955,00093,323,264
72Sep 3, 2024 19:196,709681,268,93632,026,00029,024,00093,323,264
73Sep 3, 2024 19:206,716680,960,26422,040,00039,072,00093,061,120
74Sep 3, 2024 19:206,716685,586,98436,071,00025,049,00093,229,056
75Aug 31, 2024 21:426,719683,038,30018,041,00043,098,00093,319,168
76Sep 3, 2024 19:196,720683,808,09120,048,00041,100,00093,323,264
77Sep 3, 2024 19:206,721680,978,56523,059,00038,098,00093,323,264
78Aug 31, 2024 21:426,723681,103,15724,070,00037,109,00093,323,264
79Sep 3, 2024 19:206,724683,226,07621,066,00040,126,00093,323,264
80Aug 31, 2024 21:426,727685,547,92223,080,00038,132,00093,323,264
81Aug 31, 2024 21:426,738679,124,82025,128,00036,185,00093,315,072
82Aug 31, 2024 21:426,743683,721,76028,165,00033,195,00093,323,264
83Sep 3, 2024 19:206,751687,623,75524,171,00037,264,00093,319,168
84Sep 3, 2024 19:196,764685,854,86125,225,00036,325,00093,323,264
85Sep 3, 2024 19:206,783689,355,79128,872,00032,854,00093,233,152
86Sep 3, 2024 19:206,812683,630,93432,996,00028,996,00093,224,960
87Aug 31, 2024 21:426,842683,878,31633,141,00029,124,00093,323,264