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:45M-RochatM-RochatScore: 9,502Success
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:519,46494,846,00669,717,00016,408,00094,392,320
2May 16, 2026 22:519,46594,805,13869,688,00016,446,00094,392,320
3May 16, 2026 22:519,48795,068,34969,891,00016,449,00094,392,320
4May 16, 2026 22:519,49195,018,22369,308,00017,062,00094,392,320
5May 16, 2026 22:519,50295,191,12969,401,00017,073,00094,392,320
6May 16, 2026 22:519,50496,133,91670,087,00016,405,00094,392,320
7May 16, 2026 22:519,50697,597,95469,509,00016,996,00094,392,320
8May 16, 2026 22:519,51196,500,10169,469,00017,089,00094,392,320
9May 16, 2026 22:519,522109,196,41470,150,00016,502,00094,392,320