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 listJul 3, 2026 15:24A_ShamanA_ShamanScore: 38,639Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 3, 2026 15:3138,562360,500,140299,872,00051,047,000169,893,888
2Jul 3, 2026 15:3138,564360,666,950300,475,00050,464,000169,893,888
3Jul 3, 2026 15:3138,617361,425,219300,527,00050,888,000171,991,040
4Jul 3, 2026 15:3138,628361,465,509300,507,00051,012,000169,893,888
5Jul 3, 2026 15:3138,639362,486,855300,413,00051,202,000171,991,040
6Jul 3, 2026 15:3138,652361,334,401300,653,00051,083,000171,991,040
7Jul 3, 2026 15:3138,712362,297,404300,753,00051,529,000169,893,888
8Jul 3, 2026 15:3138,747374,099,831301,061,00051,544,000169,893,888
9Jul 3, 2026 15:3138,825362,851,869300,818,00052,491,000171,991,040