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 19, 2026 23:46olliecrowolliecrowError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 9, 2026 11:02Tomislav Tunkovic10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 9, 2026 11:06091,942,77164,626,00016,325,00088,100,864diff: map[string]any{ "age": s"55", - "height": s"175.4", + "height": s"17540e-2", "id": s"411546", "married": bool(false), "phones": []any{map[string]any{"code": string("+0"), "number": s"1715707227"}}, }
2Sep 9, 2026 11:06091,458,72964,053,00016,387,00088,100,864diff: map[string]any{ + "age": s"27", - "height": s"172.2", - "id": s"748729", + "id": s"865611", "married": bool(true), - "phones": []any{ - map[string]any{"code": string("+3"), "number": s"1499957748"}, - map[string]any{"...
3Sep 9, 2026 11:06091,682,58064,334,00016,450,00088,100,864invalid character 'i' looking for beginning of value
4Mar 19, 2026 23:466,77489,483,88341,756,00019,884,00094,539,776
5Mar 19, 2026 23:466,78389,135,90240,819,00020,907,00094,564,352
6Mar 19, 2026 23:466,79585,163,23240,891,00020,944,00094,552,064