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 13, 2026 16:08KeefeKeefeError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 4, 2026 11:00Tomislav Tunkovic107.46CustomSolution Broken
Jul 6, 2026 12:36Victor Mercklé107.46CustomSolution Held
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 4, 2026 11:01010,615,091841,00002,117,632invalid character ',' looking for beginning of value
2Sep 4, 2026 11:01010,589,300925,00002,117,632invalid character '0' after object key:value pair
3Sep 4, 2026 11:01010,537,128927,00002,117,632diff: map[string]any{ "age": s"58", - "height": s"178", + "height": s"178.00", "id": s"743723", "married": bool(true), "phones": []any{map[string]any{"code": string("+6"), "number": s"1105658316"}}, }
4Mar 13, 2026 16:086,04182,048,90829,984,00024,987,00094,629,888
5Mar 13, 2026 16:086,05084,536,92328,029,00027,028,00094,629,888
6Mar 13, 2026 16:086,05580,772,41628,052,00027,050,00094,629,888
7Mar 13, 2026 16:086,06881,062,77129,114,00026,102,00094,752,768
8Mar 13, 2026 16:086,07979,694,85930,176,00025,147,00094,621,696
9Mar 13, 2026 16:086,08983,047,32329,214,00026,192,00094,621,696
10Mar 13, 2026 16:086,09279,817,62327,215,00028,223,00094,593,024
11Mar 13, 2026 16:086,10781,508,21426,796,00028,781,00094,629,888
12Mar 13, 2026 16:086,11680,431,63424,848,00030,812,00094,785,536