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 15, 2026 14:14olliecrowolliecrowScore: 8,392Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 15, 2026 14:208,36385,161,36259,959,00016,151,00092,299,264
2May 15, 2026 14:208,36384,931,55759,746,00016,360,00092,299,264
3May 15, 2026 14:208,37387,388,29159,766,00016,433,00092,299,264
4May 15, 2026 14:208,37585,037,10759,683,00016,532,00092,299,264
5May 15, 2026 14:208,39285,144,03059,780,00016,595,00092,299,264
6May 15, 2026 14:208,39587,089,10960,004,00016,394,00092,299,264
7May 15, 2026 14:208,40485,502,74059,928,00016,556,00092,299,264
8May 15, 2026 14:208,40785,326,54460,143,00016,365,00092,299,264
9May 15, 2026 14:208,42685,580,58560,014,00016,664,00092,299,264