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 1, 2025 01:02KeefeKeefeScore: 27,138Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 1, 2025 01:0227,068277,376,089224,377,00021,939,00094,654,464
2May 1, 2025 01:0227,081269,749,591224,487,00021,949,00094,662,656
3May 1, 2025 01:0227,093277,266,345223,588,00022,957,00094,662,656
4May 1, 2025 01:0227,093268,051,890230,579,00015,970,00094,666,752
5May 1, 2025 01:0227,138270,784,230226,962,00019,996,00094,797,824
6May 1, 2025 01:0227,170273,592,054226,308,00020,935,00094,552,064
7May 1, 2025 01:0227,237270,719,223225,873,00021,987,00094,658,560
8May 1, 2025 01:0227,284272,252,480225,347,00022,933,00094,621,696
9May 1, 2025 01:0227,394276,920,737224,356,00024,928,00094,543,872