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 21, 2026 16:42M-RochatM-RochatScore: 5,535Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 21, 2026 16:475,49060,860,32233,609,00016,355,00094,392,320
2May 21, 2026 16:475,50260,111,45233,655,00016,422,00094,392,320
3May 21, 2026 16:475,51162,573,63833,679,00016,480,00094,392,320
4May 21, 2026 16:475,52659,637,99033,685,00016,603,00094,392,320
5May 21, 2026 16:475,53560,613,01933,332,00017,039,00094,392,320
6May 21, 2026 16:475,53559,549,20233,733,00016,642,00094,392,320
7May 21, 2026 16:475,54659,720,90233,738,00016,735,00094,392,320
8May 21, 2026 16:475,55062,951,07733,763,00016,742,00094,392,320
9May 21, 2026 16:475,67760,875,58835,197,00016,466,00094,392,320