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 listSep 4, 2026 20:20Tomislav TunkovicTomislav TunkovicError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 10, 2026 23:11Andrew Epstein152.94CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 10, 2026 23:130620,479,906568,773,00041,629,000132,149,248diff: map[string]any{ "age": s"255", - "height": s"169.1", + "height": s"0", "id": s"4294967295", "married": bool(true), "phones": []any{map[string]any{"code": string("false"), "number": s"18446744073709551615"}, map[string]...
2Sep 10, 2026 23:130620,921,597568,726,00042,182,000134,246,400diff: map[string]any{ "age": s"255", - "height": s"169.1", + "height": s"0", "id": s"4294967295", "married": bool(true), "phones": []any{map[string]any{"code": string("false"), "number": s"18446744073709551615"}, map[string]...
3Sep 10, 2026 23:130621,024,077568,541,00042,481,000134,250,496diff: map[string]any{ "age": s"255", - "height": s"169.1", + "height": s"0", "id": s"4294967295", "married": bool(true), "phones": []any{map[string]any{"code": string("false"), "number": s"18446744073709551615"}, map[string]...
4Sep 4, 2026 20:292,90336,122,83017,567,0008,858,00092,737,536
5Sep 4, 2026 20:292,90638,715,50917,560,0008,892,00092,708,864
6Sep 4, 2026 20:292,90837,582,17217,006,0009,460,00092,749,824
7Sep 4, 2026 20:292,91036,261,29517,011,0009,470,00092,770,304
8Sep 4, 2026 20:292,91136,141,62217,644,0008,850,00092,774,400
9Sep 4, 2026 20:292,91636,244,26017,582,0008,954,00092,790,784
10Sep 4, 2026 20:292,92336,402,55217,052,0009,555,00092,766,208
11Sep 4, 2026 20:292,92536,410,29517,057,0009,563,00092,762,112
12Sep 4, 2026 20:292,92737,705,06417,073,0009,568,00092,696,576