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 18:58marko1597marko1597Score: 4,169Success
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 19:324,15846,900,73025,517,00012,321,00092,790,784stderr
2Aug 14, 2026 19:324,16146,879,69025,479,00012,388,00092,708,864stderr
3Aug 14, 2026 19:324,16546,930,14625,530,00012,375,00092,749,824stderr
4Aug 14, 2026 19:324,16847,019,54325,459,00012,473,00092,741,632stderr
5Aug 14, 2026 19:324,16946,996,61925,536,00012,408,00092,692,480stderr
6Aug 14, 2026 19:324,17147,054,00625,507,00012,458,00092,745,728stderr
7Aug 14, 2026 19:324,17346,419,93725,586,00012,397,00092,762,112stderr
8Aug 14, 2026 19:324,19246,459,20225,668,00012,483,00092,774,400stderr
9Aug 14, 2026 19:324,20946,638,07525,713,00012,595,00092,741,632stderr