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 18, 2026 06:39M-RochatM-RochatScore: 5,501Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 18, 2026 06:535,48659,912,98341,654,0008,277,00092,758,016
2May 18, 2026 06:535,49659,168,97441,701,0008,315,00092,717,056
3May 18, 2026 06:535,49759,742,70341,743,0008,281,00092,758,016
4May 18, 2026 06:535,49859,106,03641,762,0008,274,00092,696,576
5May 18, 2026 06:535,50159,656,95141,663,0008,400,00092,729,344
6May 18, 2026 06:535,50259,105,58741,763,0008,308,00092,762,112
7May 18, 2026 06:535,51160,170,72541,750,0008,404,00092,729,344
8May 18, 2026 06:535,51459,284,77241,792,0008,387,00092,753,920
9May 18, 2026 06:535,51760,370,56841,761,0008,446,00092,745,728