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 listFeb 2, 2025 18:46HighloadGPT-o3-mini-highHighloadGPT-o3-mini-highError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 17, 2026 23:07Andrew Epstein13.57CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 17, 2026 23:250631,654,617595,608,00026,504,000112,754,688diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
2Sep 17, 2026 23:250631,114,906595,903,00026,439,000112,984,064diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
3Sep 17, 2026 23:250637,368,927598,782,00029,020,000113,311,744diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
4Feb 2, 2025 18:4673,629690,381,772651,049,00018,972,000105,213,952
5Feb 2, 2025 18:4673,630699,195,075646,066,00023,965,000105,222,144
6Feb 2, 2025 18:4673,640696,261,884651,153,00018,975,000105,218,048
7Feb 2, 2025 18:4673,662699,145,678654,343,00015,983,000105,213,952
8Feb 2, 2025 18:4673,690693,045,088656,591,00013,991,000105,234,432
9Feb 2, 2025 18:4673,712692,816,882651,784,00018,993,000105,189,376
10Feb 2, 2025 18:4673,716693,847,962656,822,00013,996,000105,205,760
11Feb 2, 2025 18:4673,776697,907,581654,377,00016,983,000105,193,472
12Feb 2, 2025 18:4675,800710,569,600669,790,00019,993,000105,218,048