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

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

Challenge History
DateChallengerCostTypeStatus
Sep 18, 2026 01:43Andrew Epstein10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 18, 2026 02:000239,914,709199,723,00029,821,000126,488,576diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
2Sep 18, 2026 02:000241,453,128199,219,00031,701,000126,439,424diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
3Sep 18, 2026 02:000240,721,675199,289,00031,068,000126,160,896diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
4Mar 4, 2026 00:0012,285134,724,88593,828,00017,967,00094,552,064
5Mar 4, 2026 00:0012,294139,243,39195,892,00015,982,00094,552,064
6Mar 4, 2026 00:0012,307142,156,37994,994,00016,998,00094,547,968
7Mar 4, 2026 00:0012,313142,868,22895,044,00017,007,00094,781,440
8Mar 4, 2026 00:0012,316137,170,26796,069,00016,011,00094,547,968
9Mar 4, 2026 00:0012,326138,706,41892,141,00020,030,00094,568,448
10Mar 4, 2026 00:0012,329134,947,10597,169,00015,026,00094,572,544
11Mar 4, 2026 00:0012,339137,173,31096,242,00016,040,00094,568,448
12Mar 4, 2026 00:0012,366138,594,59095,452,00017,080,00094,556,160