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 listApr 30, 2025 23:35Aniruddha DebAniruddha DebScore: 6,008Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 30, 2025 23:355,99481,016,37647,475,0007,070,00094,404,608
2Apr 30, 2025 23:365,99677,739,58345,467,0009,093,00094,408,704
3Apr 30, 2025 23:365,99775,845,15546,485,0008,084,00094,531,584
4Apr 30, 2025 23:356,00076,040,42445,664,0008,934,00094,650,368
5Apr 30, 2025 23:366,00179,565,10844,683,0009,929,00094,617,600
6Apr 30, 2025 23:366,00375,178,75746,679,0007,945,00094,359,552
7Apr 30, 2025 23:356,00683,788,72746,705,0007,949,00094,564,352
8Apr 30, 2025 23:356,00679,278,80746,703,0007,949,00094,511,104
9Apr 30, 2025 23:366,00681,022,61045,714,0008,944,00094,498,816
10Apr 30, 2025 23:356,00885,108,01147,713,0006,958,00094,527,488
11Apr 30, 2025 23:366,00976,513,31145,731,0008,947,00094,588,928
12Apr 30, 2025 23:356,01076,546,14146,733,0007,954,00094,683,136
13Apr 30, 2025 23:356,01078,841,50246,739,0007,955,00094,670,848
14Apr 30, 2025 23:356,01182,232,26146,744,0007,956,00094,683,136
15Apr 30, 2025 23:356,01277,215,98244,759,0009,946,00094,625,792
16Apr 30, 2025 23:366,01384,888,69046,762,0007,959,00094,539,776
17Apr 30, 2025 23:366,01676,976,87345,785,0008,958,00094,662,656
18Apr 30, 2025 23:366,02182,614,88546,819,0007,969,00094,535,680