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 listAug 16, 2026 13:14marko1597marko1597Score: 2,914Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 16, 2026 13:342,88534,715,21417,639,0008,616,00092,725,248stderr
2Aug 16, 2026 13:342,89134,787,90017,735,0008,576,00092,733,440stderr
3Aug 16, 2026 13:342,89234,716,24017,740,0008,582,00092,807,168stderr
4Aug 16, 2026 13:342,90134,831,29417,801,0008,605,00092,692,480stderr
5Aug 16, 2026 13:342,91434,964,54617,844,0008,675,00092,708,864stderr
6Aug 16, 2026 13:342,91534,990,80717,833,0008,700,00092,782,592stderr
7Aug 16, 2026 13:342,91635,627,52518,148,0008,394,00092,758,016stderr
8Aug 16, 2026 13:342,92335,011,89718,154,0008,448,00092,717,056stderr
9Aug 16, 2026 13:342,92535,012,25417,897,0008,726,00092,733,440stderr