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 17, 2026 08:22M-RochatM-RochatScore: 9,010Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 17, 2026 08:278,97592,456,58565,380,00016,294,00094,392,320
2May 17, 2026 08:278,97792,126,66165,376,00016,323,00094,392,320
3May 17, 2026 08:278,99390,588,94565,451,00016,388,00094,392,320
4May 17, 2026 08:279,01090,566,95364,853,00017,143,00094,392,320
5May 17, 2026 08:279,01090,756,23364,970,00017,027,00094,392,320
6May 17, 2026 08:279,01490,976,49964,928,00017,100,00094,392,320
7May 17, 2026 08:279,01590,790,15665,508,00016,530,00094,392,320
8May 17, 2026 08:279,01890,652,13264,892,00017,175,00094,392,320
9May 17, 2026 08:279,02990,758,64964,962,00017,204,00094,392,320