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 07:26M-RochatM-RochatScore: 5,231Success
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 07:385,21657,963,26739,114,0008,352,00092,766,208
2May 18, 2026 07:385,22458,303,73638,998,0008,547,00092,692,480
3May 18, 2026 07:385,22857,337,72239,046,0008,534,00092,774,400
4May 18, 2026 07:385,22956,931,59939,143,0008,443,00092,749,824
5May 18, 2026 07:385,23156,982,62939,296,0008,307,00092,721,152
6May 18, 2026 07:385,23457,602,31539,115,0008,519,00092,729,344
7May 18, 2026 07:385,23457,424,74039,259,0008,373,00092,721,152
8May 18, 2026 07:385,23758,669,55139,195,0008,468,00092,762,112
9May 18, 2026 07:385,24256,949,70639,182,0008,521,00092,753,920