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 listDec 24, 2025 03:15Josu San MartinJosu San MartinScore: 20,227Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Dec 24, 2025 03:1520,191217,269,818162,766,00020,969,00094,552,064
2Dec 24, 2025 03:1520,208208,541,795162,904,00020,987,00094,625,792
3Dec 24, 2025 03:1520,213210,599,119164,948,00018,994,00094,625,792
4Dec 24, 2025 03:1520,216209,810,560163,967,00019,996,00094,793,728
5Dec 24, 2025 03:1520,227211,664,659162,062,00022,008,00094,724,096
6Dec 24, 2025 03:1520,236207,427,067164,130,00020,015,00094,601,216
7Dec 24, 2025 03:1520,255213,548,162164,284,00020,034,00094,576,640
8Dec 24, 2025 03:1520,294215,207,262161,715,00022,959,00094,597,120
9Dec 24, 2025 03:1520,323209,804,655161,950,00022,993,00094,789,632