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:21Josu San MartinJosu San MartinScore: 20,147Success
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:2120,080210,968,190162,757,00019,970,00094,588,928
2Dec 24, 2025 03:2120,114208,196,969160,030,00023,004,00094,621,696
3Dec 24, 2025 03:2120,124209,248,680160,114,00023,016,00094,568,448
4Dec 24, 2025 03:2120,147209,375,872161,415,00021,920,00094,556,160
5Dec 24, 2025 03:2120,147211,980,173159,294,00024,044,00094,621,696
6Dec 24, 2025 03:2120,155213,806,458160,487,00022,926,00094,621,696
7Dec 24, 2025 03:2120,157209,235,320162,497,00020,935,00094,617,600
8Dec 24, 2025 03:2120,177209,443,934158,662,00024,946,00094,572,544
9Dec 24, 2025 03:2120,186211,025,965161,727,00021,962,00094,613,504