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 20, 2026 14:07olliecrowolliecrowError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 9, 2026 11:03Tomislav Tunkovic10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 9, 2026 11:070522,509,105497,932,00016,165,00094,392,320diff: map[string]any{ "age": s"25", - "height": s"199.9", + "height": s"19.99e1", "id": s"106642", "married": bool(true), }
2Sep 9, 2026 11:070522,990,472498,356,00016,193,00094,392,320invalid character '0' after object key:value pair
3Sep 9, 2026 11:070522,438,310496,931,00017,050,00094,392,320diff: map[string]any{ "age": s"66", "height": s"166.5", "id": s"942582", - "married": bool(false), }
4Mar 20, 2026 14:079,776111,359,15472,971,00015,993,00094,806,016
5Mar 20, 2026 14:079,789106,641,10674,067,00015,013,00094,543,872
6Mar 20, 2026 14:079,924115,001,71289,305,0001,003,00094,806,016