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:43M-RochatM-RochatScore: 4,967Success
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:554,95254,240,48236,697,0008,374,00092,803,072
2May 18, 2026 07:554,95954,374,29936,704,0008,424,00092,758,016
3May 18, 2026 07:554,96157,505,26236,853,0008,300,00092,721,152
4May 18, 2026 07:554,96356,515,99136,789,0008,375,00092,778,496
5May 18, 2026 07:554,96754,328,56536,811,0008,392,00092,708,864
6May 18, 2026 07:554,97054,576,35136,797,0008,435,00092,790,784
7May 18, 2026 07:554,97354,401,95736,828,0008,429,00092,733,440
8May 18, 2026 07:554,97854,535,99136,886,0008,416,00092,770,304
9May 18, 2026 07:554,98056,501,87636,971,0008,352,00092,737,536