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 02:29M-RochatM-RochatScore: 8,994Success
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 02:368,97591,842,93165,355,00016,321,00094,392,320
2May 17, 2026 02:368,99090,572,15964,711,00017,099,00094,392,320
3May 17, 2026 02:368,99192,174,59564,719,00017,101,00094,392,320
4May 17, 2026 02:368,99190,586,69164,714,00017,110,00094,392,320
5May 17, 2026 02:368,99490,560,46965,435,00016,411,00094,392,320
6May 17, 2026 02:368,99790,609,16164,766,00017,111,00094,392,320
7May 17, 2026 02:369,00091,267,61865,393,00016,516,00094,392,320
8May 17, 2026 02:369,01090,971,92964,835,00017,158,00094,392,320
9May 17, 2026 02:369,04791,001,66965,802,00016,534,00094,392,320