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 listJul 28, 2024 13:24Yuriy LyfenkoYuriy LyfenkoScore: 3,474Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 26, 2024 22:203,321653,237,92422,928,0007,295,00092,884,992
2Jul 26, 2024 22:203,325661,435,07323,201,0007,061,00092,930,048
3Jul 26, 2024 22:203,329653,244,01324,238,0006,059,00092,934,144
4Jul 26, 2024 22:203,332654,598,34022,238,0008,086,00093,048,832
5Jul 28, 2024 13:193,332651,344,62423,249,0007,075,00093,052,928
6Jul 26, 2024 22:203,333653,092,17724,267,0006,066,00092,835,840
7Jul 28, 2024 13:243,334660,554,34924,268,0006,067,00092,958,720
8Jul 28, 2024 13:193,335659,911,17222,254,0008,092,00093,179,904
9Jul 28, 2024 13:243,339654,443,90224,306,0006,076,00092,893,184
10Jul 28, 2024 13:193,339648,799,93625,318,0005,063,00093,179,904
11Jul 28, 2024 13:243,453700,538,87931,420,203094,711,808
12Jul 26, 2024 22:203,456700,775,91731,452,186094,654,464
13Jul 28, 2024 13:243,457693,385,72631,463,197094,646,272
14Jul 28, 2024 13:193,460698,659,92631,489,639094,711,808
15Jul 26, 2024 22:203,461694,449,16431,499,030094,609,408
16Jul 28, 2024 13:193,470689,352,24031,574,385094,609,408
17Jul 26, 2024 22:203,473694,840,58431,604,141094,679,040
18Jul 28, 2024 13:193,473693,268,57231,608,405094,769,152
19Jul 28, 2024 13:243,474688,234,28531,615,720094,609,408
20Jul 26, 2024 22:203,651652,220,84823,159,00010,069,00093,216,768
21Jul 28, 2024 13:243,652658,620,28821,808,00011,423,00093,224,960
22Jul 28, 2024 13:245,558678,090,25130,349,00020,233,00093,048,832
23Jul 28, 2024 13:195,702675,415,94333,924,00017,960,00093,126,656
24Jul 26, 2024 22:206,049674,345,34132,028,00023,020,00093,110,272
25Jul 28, 2024 13:196,071681,195,97631,138,00024,107,00093,106,176
26Jul 26, 2024 22:206,126687,276,27526,878,00028,869,00093,106,176
27Jul 28, 2024 13:246,634682,225,47120,124,00040,248,00093,339,648
28Jul 28, 2024 13:196,846682,621,17130,143,00032,152,00093,335,552
29Jul 28, 2024 13:197,052683,738,44635,095,00029,078,00093,319,168
30Jul 28, 2024 13:247,061687,401,59930,118,00034,134,00093,323,264
31Jul 28, 2024 13:247,063683,439,80134,145,00030,128,00093,323,264
32Jul 26, 2024 22:207,069692,005,24127,137,00037,188,00093,323,264
33Jul 28, 2024 13:247,072684,393,68438,210,00026,144,00093,323,264
34Jul 28, 2024 13:197,086692,797,89230,708,00033,779,00093,323,264
35Jul 28, 2024 13:197,087693,648,83828,216,00036,278,00093,323,264
36Jul 28, 2024 13:247,117691,599,06530,889,00033,879,00093,061,120