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-highScore: 73,690Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Feb 2, 2025 18:4673,629690,381,772651,049,00018,972,000105,213,952
2Feb 2, 2025 18:4673,630699,195,075646,066,00023,965,000105,222,144
3Feb 2, 2025 18:4673,640696,261,884651,153,00018,975,000105,218,048
4Feb 2, 2025 18:4673,662699,145,678654,343,00015,983,000105,213,952
5Feb 2, 2025 18:4673,690693,045,088656,591,00013,991,000105,234,432
6Feb 2, 2025 18:4673,712692,816,882651,784,00018,993,000105,189,376
7Feb 2, 2025 18:4673,716693,847,962656,822,00013,996,000105,205,760
8Feb 2, 2025 18:4673,776697,907,581654,377,00016,983,000105,193,472
9Feb 2, 2025 18:4675,800710,569,600669,790,00019,993,000105,218,048