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 listMar 3, 2026 22:36olliecrowolliecrowScore: 16,011Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 3, 2026 22:3615,963172,015,073128,233,00017,031,00094,547,968
2Mar 3, 2026 23:0215,974177,412,826129,325,00016,040,00094,793,728
3Mar 3, 2026 22:3615,987171,339,532132,440,00013,043,00094,556,160
4Mar 3, 2026 22:3615,990172,823,217128,566,00016,942,00094,572,544
5Mar 3, 2026 23:0215,993178,891,737127,595,00017,943,00094,572,544
6Mar 3, 2026 23:0215,996173,215,762127,619,00017,946,00094,552,064
7Mar 3, 2026 23:0215,997170,014,925127,628,00017,947,00094,556,160
8Mar 3, 2026 23:0216,003169,233,834129,668,00015,959,00094,552,064
9Mar 3, 2026 23:0216,010171,227,149128,724,00016,963,00094,547,968
10Mar 3, 2026 22:3616,011174,117,447130,730,00014,969,00094,543,872
11Mar 3, 2026 23:0216,011176,028,240130,734,00014,969,00094,543,872
12Mar 3, 2026 22:3616,012171,323,591129,743,00015,968,00094,658,560
13Mar 3, 2026 22:3616,014173,765,370126,760,00018,964,00094,547,968
14Mar 3, 2026 22:3616,025169,580,893127,848,00017,978,00094,552,064
15Mar 3, 2026 23:0216,025174,904,052131,840,00013,983,00094,576,640
16Mar 3, 2026 22:3616,044169,810,683128,000,00018,000,00094,547,968
17Mar 3, 2026 22:3616,208176,315,497128,430,00019,063,00094,552,064
18Mar 3, 2026 23:0218,099187,895,998143,738,00020,961,00094,552,064