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:50marko1597marko1597Score: 5,262Success
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:025,24356,049,12035,412,00012,301,00092,741,632stderr
2Aug 14, 2026 19:025,24356,091,50035,387,00012,326,00092,684,288stderr
3Aug 14, 2026 19:025,24556,086,31235,506,00012,229,00092,745,728stderr
4Aug 14, 2026 19:025,25956,258,46935,431,00012,431,00092,672,000stderr
5Aug 14, 2026 19:025,26256,266,23335,584,00012,305,00092,774,400stderr
6Aug 14, 2026 19:025,26857,005,60635,437,00012,508,00092,708,864stderr
7Aug 14, 2026 19:025,27856,448,81535,605,00012,433,00092,749,824stderr
8Aug 14, 2026 19:025,28056,544,93535,551,00012,500,00092,778,496stderr
9Aug 14, 2026 19:025,29056,493,02235,706,00012,436,00092,741,632stderr