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 listJun 10, 2026 00:31Victor MerckléVictor MerckléScore: 2,937Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 10, 2026 00:372,92435,552,25616,673,0009,937,00092,733,440
2Jun 10, 2026 00:372,92635,617,65016,582,00010,052,00092,786,688
3Jun 10, 2026 00:372,92937,204,24516,708,0009,947,00092,786,688
4Jun 10, 2026 00:372,93535,690,14316,779,0009,934,00092,807,168
5Jun 10, 2026 00:372,93735,723,89216,712,00010,016,00092,753,920
6Jun 10, 2026 00:372,93735,745,94216,715,00010,020,00092,721,152
7Jun 10, 2026 00:372,95935,947,22416,800,00010,129,00092,753,920
8Jun 10, 2026 00:372,95935,910,75116,805,00010,127,00092,758,016
9Jun 10, 2026 00:372,96435,926,39816,846,00010,132,00092,692,480