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 18, 2026 04:48M-RochatM-RochatError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Jul 6, 2026 13:14Victor Mercklé18.36CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 6, 2026 13:15070,373,90252,425,0008,542,00092,893,184diff:   map[string]any{ -  "age": s"51", -  "height": s"164.3", +  "height": s"51",    "id": s"517196", -  "married": bool(false), +  "married": s"64.3", -  "phones": []any{ -  map[string]any{"code": string("+8"), "number": s"171...
2Jul 6, 2026 13:15070,255,07452,438,0008,396,00092,893,184diff:   map[string]any{ -  "age": s"51", -  "height": s"164.3", +  "height": s"51",    "id": s"517196", -  "married": bool(false), +  "married": s"64.3", -  "phones": []any{ -  map[string]any{"code": string("+8"), "number": s"171...
3Jul 6, 2026 13:15070,403,94152,541,0008,441,00092,893,184diff:   map[string]any{ -  "age": s"51", -  "height": s"164.3", +  "height": s"51",    "id": s"517196", -  "married": bool(false), +  "married": s"64.3", -  "phones": []any{ -  map[string]any{"code": string("+8"), "number": s"171...
4May 18, 2026 04:537,02373,067,29855,503,0008,408,00092,712,960
5May 18, 2026 04:537,02473,086,22355,475,0008,451,00092,774,400
6May 18, 2026 04:537,02673,186,10955,465,0008,473,00092,692,480
7May 18, 2026 04:537,03073,161,15255,571,0008,406,00092,749,824
8May 18, 2026 04:537,03773,283,58755,672,0008,373,00092,733,440
9May 18, 2026 04:537,04276,271,93655,561,0008,528,00092,733,440
10May 18, 2026 04:537,04475,142,71855,691,0008,416,00092,762,112
11May 18, 2026 04:537,05473,468,76355,793,0008,399,00092,737,536
12May 18, 2026 04:537,06176,857,83755,767,0008,490,00092,790,784