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:09M-RochatM-RochatScore: 5,351Success
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:215,33957,973,21640,228,0008,364,00092,721,152
2May 18, 2026 07:215,33957,793,38940,229,0008,361,00092,712,960
3May 18, 2026 07:215,34757,786,36840,359,0008,305,00092,729,344
4May 18, 2026 07:215,34857,809,68240,294,0008,379,00092,762,112
5May 18, 2026 07:215,35158,553,84240,319,0008,380,00092,778,496
6May 18, 2026 07:215,35457,860,43840,254,0008,469,00092,708,864
7May 18, 2026 07:215,35758,506,64240,420,0008,330,00092,741,632
8May 18, 2026 07:215,35957,901,34040,416,0008,352,00092,704,768
9May 18, 2026 07:215,37958,986,68040,473,0008,480,00092,778,496