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 16:17AnSaAnSaScore: 3,634Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Dec 13, 2024 16:143,59568,013,29919,824,00012,886,00097,419,264
2Sep 3, 2024 16:173,59756,586,77019,836,00012,893,00097,386,496
3Sep 3, 2024 16:173,60363,765,13319,872,00012,917,00097,263,616
4Dec 13, 2024 16:143,61159,378,32319,916,00012,945,00097,202,176
5Sep 3, 2024 16:173,61560,525,41217,943,00014,953,00097,165,312
6Sep 3, 2024 16:173,61661,338,72118,945,00013,959,00097,222,656
7Dec 13, 2024 16:143,62258,311,63419,976,00012,984,00097,222,656
8Sep 3, 2024 16:173,62562,733,83523,992,0008,997,00097,189,888
9Dec 13, 2024 16:143,62558,742,28617,993,00014,994,00097,185,792
10Sep 3, 2024 16:173,62659,666,65415,997,00016,997,00097,251,328
11Sep 3, 2024 16:173,63058,573,70618,018,00015,015,00097,193,984
12Sep 3, 2024 16:173,63360,042,73818,035,00015,029,00097,198,080
13Dec 13, 2024 16:143,63361,447,32620,036,00013,023,00097,255,424
14Dec 13, 2024 16:143,63458,853,08118,036,00015,030,00097,157,120
15Dec 13, 2024 16:143,63661,391,35418,048,00015,040,00097,206,272
16Dec 13, 2024 16:143,63859,201,26619,062,00014,045,00097,259,520
17Dec 13, 2024 16:143,64360,933,63019,086,00014,063,00097,251,328
18Sep 3, 2024 16:173,65361,034,80319,141,00014,104,00097,259,520
19Sep 3, 2024 16:173,88559,857,01320,205,00015,153,00097,452,032
20Sep 3, 2024 16:174,19962,278,58121,118,00017,096,00097,554,432
21Sep 3, 2024 16:174,67273,185,78518,222,00024,296,00097,435,648
22Sep 3, 2024 16:176,83493,013,83324,075,00038,118,00097,603,584
23Sep 3, 2024 16:178,471102,804,86926,030,00051,059,00097,632,256
24Sep 3, 2024 16:178,552105,274,33629,930,00047,889,00097,673,216
25Sep 3, 2024 16:178,675111,811,50330,978,00047,966,00097,718,272
26Sep 3, 2024 16:178,773111,601,20026,944,00052,891,00097,751,040
27Sep 3, 2024 16:178,875107,328,08325,925,00054,841,00097,734,656