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 16, 2026 22:30M-RochatM-RochatScore: 10,442Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 16, 2026 22:3710,385105,197,49572,624,00021,887,00094,392,320
2May 16, 2026 22:3710,415106,287,94472,850,00021,931,00094,392,320
3May 16, 2026 22:3710,419105,372,74572,842,00021,977,00094,392,320
4May 16, 2026 22:3710,427103,586,29672,706,00022,180,00094,392,320
5May 16, 2026 22:3710,442103,683,38072,915,00022,116,00094,392,320
6May 16, 2026 22:3710,473104,357,69772,773,00022,535,00094,392,320
7May 16, 2026 22:3710,494105,166,30573,538,00021,963,00094,392,320
8May 16, 2026 22:3710,495104,161,89972,717,00022,791,00094,392,320
9May 16, 2026 22:3710,718107,091,85173,398,00024,143,00094,392,320