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 listMar 4, 2026 05:56olliecrowolliecrowScore: 8,213Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 4, 2026 05:568,19398,975,98858,653,00015,905,00094,793,728
2Mar 4, 2026 05:568,198102,730,93456,696,00017,904,00094,572,544
3Mar 4, 2026 05:568,20998,745,55856,776,00017,929,00094,556,160
4Mar 4, 2026 05:568,21096,356,70159,766,00014,941,00094,552,064
5Mar 4, 2026 05:568,21398,035,18058,792,00015,943,00094,658,560
6Mar 4, 2026 05:568,232100,789,25256,933,00017,979,00094,572,544
7Mar 4, 2026 05:568,243100,959,31357,009,00018,003,00094,543,872
8Mar 4, 2026 05:568,24498,533,53258,014,00017,004,00094,552,064
9Mar 4, 2026 05:568,266106,020,04159,175,00016,047,00094,552,064