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 03:11M-RochatM-RochatScore: 9,461Success
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 03:189,42696,382,10369,494,00016,283,00094,392,320
2May 17, 2026 03:189,42894,523,93869,583,00016,216,00094,392,320
3May 17, 2026 03:189,44194,866,51869,763,00016,155,00094,392,320
4May 17, 2026 03:189,45696,963,47069,627,00016,423,00094,392,320
5May 17, 2026 03:189,46197,605,06469,546,00016,550,00094,392,320
6May 17, 2026 03:189,46594,743,72669,573,00016,567,00094,392,320
7May 17, 2026 03:189,46595,178,09269,651,00016,488,00094,392,320
8May 17, 2026 03:189,46695,098,52469,678,00016,469,00094,392,320
9May 17, 2026 03:189,48398,188,84669,116,00017,185,00094,392,320