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 05:35M-RochatM-RochatScore: 8,521Success
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 05:418,50089,304,57869,030,0008,327,00092,741,632
2May 18, 2026 05:418,50388,457,59769,101,0008,284,00092,708,864
3May 18, 2026 05:418,51487,113,80369,101,0008,379,00092,753,920
4May 18, 2026 05:418,52186,778,02569,124,0008,425,00092,811,264
5May 18, 2026 05:418,52186,682,79269,216,0008,327,00092,766,208
6May 18, 2026 05:418,52686,762,32469,164,0008,428,00092,770,304
7May 18, 2026 05:418,53388,983,66369,232,0008,422,00092,733,440
8May 18, 2026 05:418,53486,771,02369,268,0008,394,00092,758,016
9May 18, 2026 05:418,62289,785,18170,142,0008,322,00092,766,208