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 14, 2026 14:18marko1597marko1597Error
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 4, 2026 10:54Tomislav Tunkovic18.40CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 4, 2026 10:56010,643,4151,068,00002,121,728EOFstderr
2Sep 4, 2026 10:56010,562,2101,050,00002,121,728EOFstderr
3Sep 4, 2026 10:56010,628,0211,067,00002,121,728diff: map[string]any{ - "age": s"45", "height": s"163.9", "id": s"328211", "married": bool(false), } stderr
4Aug 14, 2026 14:256,97573,302,29842,783,00020,692,00094,396,416stderr
5Aug 14, 2026 14:256,97673,426,38442,717,00020,766,00094,396,416stderr
6Aug 14, 2026 14:256,99074,523,37642,786,00020,828,00094,396,416stderr
7Aug 14, 2026 14:257,01073,586,16642,860,00020,934,00094,396,416stderr
8Aug 14, 2026 14:257,02273,708,57742,897,00021,004,00094,396,416stderr
9Aug 14, 2026 14:257,02873,858,02243,088,00020,867,00094,396,416stderr
10Aug 14, 2026 14:257,03973,830,97642,975,00021,087,00094,396,416stderr
11Aug 14, 2026 14:257,04173,949,67842,935,00021,145,00094,396,416stderr
12Aug 14, 2026 14:257,05373,984,70643,158,00021,032,00094,396,416stderr