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:32M-RochatM-RochatScore: 5,211Success
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:445,19856,816,95438,998,0008,312,00092,758,016
2May 18, 2026 07:445,20156,683,18538,993,0008,342,00092,717,056
3May 18, 2026 07:445,20657,324,95839,010,0008,368,00092,798,976
4May 18, 2026 07:445,20859,676,61239,028,0008,367,00092,737,536
5May 18, 2026 07:445,21156,690,74838,978,0008,445,00092,721,152
6May 18, 2026 07:445,21256,699,29738,990,0008,444,00092,712,960
7May 18, 2026 07:445,21557,903,99738,995,0008,466,00092,786,688
8May 18, 2026 07:445,21956,924,43439,059,0008,437,00092,737,536
9May 18, 2026 07:445,21956,882,48638,982,0008,514,00092,786,688