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 26, 2024 21:51Yuriy LyfenkoYuriy LyfenkoScore: 3,597Success
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 21:513,387655,342,58916,904,00013,921,00093,188,096
2Jul 26, 2024 21:513,395653,647,57318,936,00011,959,00092,930,048
3Jul 26, 2024 21:503,396653,236,39315,952,00014,955,00092,946,432
4Jul 26, 2024 21:503,397656,930,92415,953,00014,956,00093,159,424
5Jul 26, 2024 21:503,399658,853,10219,591,00011,342,00092,971,008
6Jul 26, 2024 21:503,400661,461,81315,969,00014,971,00093,184,000
7Jul 26, 2024 21:513,401660,162,82018,971,00011,981,00092,930,048
8Jul 26, 2024 21:503,401653,213,81017,969,00012,978,00093,151,232
9Jul 26, 2024 21:513,401661,463,23015,975,00014,976,00093,138,944
10Jul 26, 2024 21:513,405657,824,48916,990,00013,991,00092,925,952
11Jul 26, 2024 21:503,407652,178,01219,001,00012,001,00092,864,512
12Jul 26, 2024 21:503,594696,451,50632,706,741094,613,504
13Jul 26, 2024 21:513,597702,945,33132,732,235094,654,464
14Jul 26, 2024 21:503,598698,081,21632,743,216094,654,464
15Jul 26, 2024 21:513,599700,061,35732,749,525094,609,408
16Jul 26, 2024 21:503,604684,166,21432,793,674094,609,408
17Jul 26, 2024 21:513,610702,670,33432,849,503094,613,504
18Jul 26, 2024 21:514,253662,012,98519,349,00019,349,00093,110,272
19Jul 26, 2024 21:515,610675,595,24822,023,00029,031,00093,130,752
20Jul 26, 2024 21:515,721678,651,82431,035,00021,024,00093,130,752
21Jul 26, 2024 21:505,977674,609,03225,180,00029,209,00093,118,464
22Jul 26, 2024 21:506,656693,298,86133,314,00027,257,00093,343,744
23Jul 26, 2024 21:507,150685,279,30130,030,00035,035,00093,237,248
24Jul 26, 2024 21:517,155692,385,44429,050,00036,063,00093,061,120