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 6, 2026 11:00olliecrowolliecrowError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 9, 2026 02:24Haha Expert10.00CustomSolution Broken
Jul 6, 2026 08:41Victor Mercklé10.00CustomSolution Held
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 9, 2026 02:40011,216,83101,507,0002,117,632diff: map[string]any{ - "age": s"123", + "age": s"12", "height": s"456.7", "id": s"1", "married": bool(false), }
2Sep 9, 2026 02:40011,195,51001,508,0002,117,632diff: map[string]any{ - "age": s"123", + "age": s"12", "height": s"456.7", "id": s"1", "married": bool(false), }
3Sep 9, 2026 02:40011,213,96301,509,0002,117,632diff: map[string]any{ - "age": s"123", + "age": s"12", "height": s"456.7", "id": s"1", "married": bool(false), }
4May 6, 2026 11:064,12155,796,94920,871,00016,635,00092,569,600
5May 6, 2026 11:064,12754,314,32720,916,00016,641,00092,565,504
6May 6, 2026 11:064,13254,948,93120,923,00016,685,00092,549,120
7May 6, 2026 11:064,13554,872,91320,889,00016,740,00092,569,600
8May 6, 2026 11:064,13554,755,09820,859,00016,770,00092,565,504
9May 6, 2026 11:064,14653,891,80420,916,00016,815,00092,565,504
10May 6, 2026 11:064,16754,916,68121,069,00016,853,00092,569,600
11May 6, 2026 11:064,17256,471,28621,106,00016,861,00092,569,600
12May 6, 2026 11:064,18756,305,71520,600,00017,510,00092,561,408