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 08:01M-RochatM-RochatScore: 4,970Success
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 08:124,95054,280,80336,684,0008,370,00092,688,384
2May 18, 2026 08:124,95254,212,41736,766,0008,301,00092,692,480
3May 18, 2026 08:124,96254,361,03136,805,0008,350,00092,708,864
4May 18, 2026 08:124,96755,055,54836,772,0008,436,00092,745,728
5May 18, 2026 08:124,97054,313,89636,828,0008,403,00092,778,496
6May 18, 2026 08:124,97257,152,31136,813,0008,434,00092,766,208
7May 18, 2026 08:124,97655,324,25336,819,0008,470,00092,803,072
8May 18, 2026 08:124,98854,611,88736,987,0008,409,00092,782,592
9May 18, 2026 08:124,99057,593,88436,910,0008,504,00092,766,208