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 09:17marko1597marko1597Error
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 4, 2026 18:34Tomislav Tunkovic35.88CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 4, 2026 18:42011,232,35001,222,00028,672EOFstderr
2Sep 4, 2026 18:4209,356,68201,186,00028,672EOFstderr
3Sep 4, 2026 18:4209,341,10001,202,00028,672diff: map[string]any{ "age": s"8", "height": s"0", "id": s"726920", - "married": bool(true), + "married": bool(false), } stderr
4Aug 16, 2026 09:452,90434,828,08717,811,0008,619,00092,762,112stderr
5Aug 16, 2026 09:452,90634,812,27517,826,0008,621,00092,794,880stderr
6Aug 16, 2026 09:452,91134,926,51917,823,0008,672,00092,647,424stderr
7Aug 16, 2026 09:452,91234,898,04217,879,0008,624,00092,700,672stderr
8Aug 16, 2026 09:452,91734,915,88218,142,0008,411,00092,745,728stderr
9Aug 16, 2026 09:452,92234,973,21817,904,0008,695,00092,733,440stderr
10Aug 16, 2026 09:452,92334,951,37618,184,0008,417,00092,708,864stderr
11Aug 16, 2026 09:452,93135,121,77417,965,0008,716,00092,815,360stderr
12Aug 16, 2026 09:452,93635,145,03718,246,0008,476,00092,733,440stderr