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 15, 2026 22:04marko1597marko1597Score: 3,668Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 15, 2026 22:183,65841,647,03224,939,0008,354,00092,745,728stderr
2Aug 15, 2026 22:183,66041,690,73024,981,0008,326,00092,762,112stderr
3Aug 15, 2026 22:183,66341,762,92124,994,0008,344,00092,758,016stderr
4Aug 15, 2026 22:183,66841,777,26624,992,0008,388,00092,782,592stderr
5Aug 15, 2026 22:183,66841,807,61125,016,0008,368,00092,758,016stderr
6Aug 15, 2026 22:183,67241,954,76925,081,0008,337,00092,741,632stderr
7Aug 15, 2026 22:183,67841,841,72125,091,0008,381,00092,733,440stderr
8Aug 15, 2026 22:183,68242,645,56125,047,0008,463,00092,794,880stderr
9Aug 15, 2026 22:183,68741,845,81925,067,0008,485,00092,741,632stderr