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 listMar 13, 2026 12:05Dominique GarmierDominique GarmierError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 17, 2026 21:25Andrew Epstein39.42CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 17, 2026 21:380413,329,913370,934,00031,498,000126,562,304diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
2Sep 17, 2026 21:380412,795,616371,127,00030,071,000126,332,928diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
3Sep 17, 2026 21:380411,371,475370,808,00030,088,000126,496,768diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
4Mar 13, 2026 12:0525,306252,561,208214,339,00015,950,00094,539,776
5Mar 13, 2026 12:0525,314256,697,439207,421,00022,936,00094,793,728
6Mar 13, 2026 12:0525,352261,477,023209,734,00020,973,00094,797,824
7Mar 13, 2026 12:0525,358256,919,125212,777,00017,981,00094,556,160
8Mar 13, 2026 12:0525,369251,085,052217,869,00012,992,00094,621,696
9Mar 13, 2026 12:0525,371257,931,374212,889,00017,990,00094,785,536
10Mar 13, 2026 12:0525,377256,979,162212,939,00017,994,00094,785,536
11Mar 13, 2026 12:0525,405262,767,002211,260,00019,930,00094,785,536
12Mar 13, 2026 12:0525,447257,285,297215,595,00015,970,00094,547,968