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 listMay 31, 2025 15:33KeefeKeefeScore: 17,532Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 31, 2025 15:3317,484188,942,658138,091,00021,013,00094,576,640
2May 31, 2025 15:3317,515189,904,908137,330,00022,053,00094,539,776
3May 31, 2025 15:3317,517190,928,015138,354,00021,054,00094,547,968
4May 31, 2025 15:3317,528189,259,216135,583,00023,926,00094,539,776
5May 31, 2025 15:3317,532188,960,136136,606,00022,933,00094,539,776
6May 31, 2025 15:3317,533190,796,322136,615,00022,935,00094,539,776
7May 31, 2025 15:3317,562182,876,030135,846,00023,972,00094,543,872
8May 31, 2025 15:3317,598182,840,217135,121,00025,022,00094,543,872
9May 31, 2025 15:3317,634184,808,994136,551,00023,921,00094,543,872