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 02:33olliecrowolliecrowScore: 11,014Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 4, 2026 02:3310,949126,903,55384,689,00014,945,00094,552,064
2Mar 4, 2026 02:3310,955123,166,36383,739,00015,950,00094,654,464
3Mar 4, 2026 02:3310,974123,918,08282,886,00016,976,00094,560,256
4Mar 4, 2026 02:3311,000126,497,04879,076,00021,020,00094,572,544
5Mar 4, 2026 02:3311,014130,851,16481,183,00019,043,00094,547,968
6Mar 4, 2026 02:3311,027122,831,97088,307,00012,041,00094,568,448
7Mar 4, 2026 02:3311,138136,816,45284,461,00016,892,00094,568,448
8Mar 4, 2026 02:3311,174135,376,28686,873,00014,807,00094,564,352
9Mar 4, 2026 02:3311,203124,582,49784,956,00016,991,00094,572,544