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 listApr 24, 2026 17:14olliecrowolliecrowScore: 5,997Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 24, 2026 17:185,98462,855,77334,287,00020,168,00094,588,928
2Apr 24, 2026 17:185,98763,009,22530,709,00023,775,00094,633,984
3Apr 24, 2026 17:185,98862,889,44631,283,00023,210,00094,654,464
4Apr 24, 2026 17:185,99162,837,21434,328,00020,193,00094,654,464
5Apr 24, 2026 17:185,99774,975,69533,736,00020,837,00094,851,072
6Apr 24, 2026 17:186,03263,175,46135,932,00018,964,00094,654,464
7Apr 24, 2026 17:186,05062,585,86944,049,00011,012,00094,654,464
8Apr 24, 2026 17:186,05363,619,77940,063,00015,023,00094,633,984
9Apr 24, 2026 17:186,13963,189,19433,920,00021,948,00094,633,984