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 listMar 20, 2026 05:29olliecrowolliecrowScore: 4,356Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 20, 2026 05:294,31964,430,04923,180,00016,125,00094,679,040
2Mar 20, 2026 05:294,32869,827,13219,691,00019,691,00094,679,040
3Mar 20, 2026 05:294,34865,772,04421,763,00017,806,00094,547,968
4Mar 20, 2026 05:294,35070,019,09222,764,00016,825,00094,793,728
5Mar 20, 2026 05:294,35665,387,75022,791,00016,846,00094,547,968
6Mar 20, 2026 05:294,35760,638,98720,818,00018,835,00094,547,968
7Mar 20, 2026 05:294,36265,267,04721,833,00017,863,00094,679,040
8Mar 20, 2026 05:294,36565,974,55224,826,00014,896,00094,683,136
9Mar 20, 2026 05:294,36764,282,94623,846,00015,897,00094,670,848