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 listMay 18, 2026 07:03M-RochatM-RochatScore: 5,424Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 18, 2026 07:165,41058,313,77040,941,0008,294,00092,684,288
2May 18, 2026 07:165,41258,381,63640,981,0008,271,00092,725,248
3May 18, 2026 07:165,41358,646,23140,910,0008,351,00092,729,344
4May 18, 2026 07:165,42159,741,51740,931,0008,409,00092,753,920
5May 18, 2026 07:165,42460,154,93740,999,0008,362,00092,778,496
6May 18, 2026 07:165,42958,638,64541,076,0008,330,00092,708,864
7May 18, 2026 07:165,43158,568,82140,962,0008,464,00092,745,728
8May 18, 2026 07:165,43359,059,45140,952,0008,493,00092,733,440
9May 18, 2026 07:165,43358,690,50341,042,0008,405,00092,753,920