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 listMay 5, 2026 06:21Victor MerckléVictor MerckléError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 5, 2026 00:21Tomislav Tunkovic10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 5, 2026 01:53034,790,80220,976,0005,625,00066,273,280invalid character 's' looking for beginning of value
2Sep 5, 2026 01:53034,677,27920,228,0006,393,00066,265,088diff: map[string]any{ - "age": s"59", - "height": s"186.3", + "height": s"186", "id": s"475888", "married": bool(false), - "phones": []any{ - map[string]any{"code": string("+7"), "number": s"1129774689"}, - map[string]any{"co...
3Sep 5, 2026 01:53034,626,61621,020,0005,552,00066,211,840invalid character 's' looking for beginning of value
4May 5, 2026 06:323,17135,568,60320,187,0008,672,00093,110,272
5May 5, 2026 06:323,19335,604,36920,254,0008,803,00093,143,040
6May 5, 2026 06:323,20335,765,65120,346,0008,809,00093,089,792
7May 5, 2026 06:323,22136,384,16520,520,0008,792,00093,077,504
8May 5, 2026 06:323,22235,602,91220,534,0008,792,00093,065,216
9May 5, 2026 06:323,22336,036,49120,445,0008,887,00093,143,040
10May 5, 2026 06:323,23635,874,95220,628,0008,826,00093,110,272
11May 5, 2026 06:323,24435,257,98720,669,0008,855,00093,093,888
12May 5, 2026 06:323,24637,047,73120,595,0008,950,00093,159,424