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:16Victor MerckléVictor MerckléError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 4, 2026 13:23Tomislav Tunkovic10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 4, 2026 13:30044,756,50121,009,0005,505,00066,224,128diff: map[string]any{ ... // 2 identical entries "id": s"63385", "married": bool(false), - "phones": []any{map[string]any{"code": string("+5"), "number": s"1654195162"}}, }
2Sep 4, 2026 13:30034,753,85620,841,0005,497,00066,215,936diff: map[string]any{ ... // 2 identical entries "id": s"714912", "married": bool(false), - "phones": []any{ - map[string]any{"code": string("+8"), "number": s"1757470013"}, - map[string]any{"code": string("+3"), "number": s"181707...
3Sep 4, 2026 13:30034,747,53020,858,0005,459,00066,207,744diff: map[string]any{ - "height": s"168.5", + "height": s"0.0", "id": s"663347", "married": bool(true), - "phones": []any{map[string]any{"code": string("+6"), "number": s"1278206503"}}, }
4May 5, 2026 06:263,11243,863,89619,381,0008,942,00093,081,600
5May 5, 2026 06:263,13142,346,29019,443,0009,051,00093,114,368
6May 5, 2026 06:263,13344,803,36619,934,0008,579,00093,151,232
7May 5, 2026 06:263,13444,173,89119,921,0008,599,00093,151,232
8May 5, 2026 06:263,14242,572,21919,792,0008,808,00093,106,176
9May 5, 2026 06:263,14944,283,53319,987,0008,672,00093,122,560
10May 5, 2026 06:263,15143,694,73319,944,0008,733,00093,118,464
11May 5, 2026 06:263,15244,485,37920,070,0008,621,00093,085,696
12May 5, 2026 06:263,15241,375,37620,031,0008,658,00093,102,080