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:48HighloadGPT-o3-mini-highHighloadGPT-o3-mini-highScore: 72,656Success
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:4872,572685,773,914645,418,00014,986,000105,086,976
2Feb 2, 2025 18:4872,616679,915,245642,808,00017,994,000105,213,952
3Feb 2, 2025 18:4872,627686,557,434642,909,00017,997,000105,213,952
4Feb 2, 2025 18:4872,651681,911,524647,118,00014,002,000105,242,624
5Feb 2, 2025 18:4872,656694,619,451640,193,00020,973,000105,189,376
6Feb 2, 2025 18:4872,675690,587,782644,363,00016,983,000105,246,720
7Feb 2, 2025 18:4872,693683,716,969643,524,00017,986,000105,242,624
8Feb 2, 2025 18:4872,698685,099,889644,566,00016,988,000105,082,880
9Feb 2, 2025 18:4872,742690,767,596648,950,00012,999,000105,189,376