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 listAug 14, 2026 15:18marko1597marko1597Score: 5,664Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 14, 2026 15:365,62561,009,31938,809,00012,380,00092,770,304stderr
2Aug 14, 2026 15:365,62761,064,11038,711,00012,497,00092,758,016stderr
3Aug 14, 2026 15:365,66062,106,02338,969,00012,538,00092,700,672stderr
4Aug 14, 2026 15:365,66061,311,94238,940,00012,570,00092,819,456stderr
5Aug 14, 2026 15:365,66461,280,21938,939,00012,610,00092,712,960stderr
6Aug 14, 2026 15:365,66561,387,25138,959,00012,595,00092,762,112stderr
7Aug 14, 2026 15:365,68661,464,90939,056,00012,687,00092,745,728stderr
8Aug 14, 2026 15:365,69661,596,98039,101,00012,740,00092,766,208stderr
9Aug 14, 2026 15:365,70961,758,15839,474,00012,481,00092,778,496stderr