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 16, 2026 08:43marko1597marko1597Score: 3,258Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 16, 2026 09:153,23937,802,06321,195,0008,288,00092,758,016stderr
2Aug 16, 2026 09:153,24037,846,31221,192,0008,296,00092,733,440stderr
3Aug 16, 2026 09:153,24137,811,27621,170,0008,326,00092,774,400stderr
4Aug 16, 2026 09:153,25137,914,01821,222,0008,364,00092,741,632stderr
5Aug 16, 2026 09:153,25838,693,95321,274,0008,378,00092,762,112stderr
6Aug 16, 2026 09:153,26138,028,89321,285,0008,397,00092,667,904stderr
7Aug 16, 2026 09:153,27638,219,39821,269,0008,550,00092,708,864stderr
8Aug 16, 2026 09:153,27938,226,65821,365,0008,479,00092,794,880stderr
9Aug 16, 2026 09:153,27938,214,63121,339,0008,504,00092,782,592stderr