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 listJun 23, 2024 16:30AnSaAnSaScore: 6,928Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 23, 2024 16:304,00763,022,26925,324,00011,142,00091,885,568
2Jun 23, 2024 16:304,04161,705,84023,850,00012,919,00091,926,528
3Jun 23, 2024 16:304,04963,517,36923,899,00012,945,00091,885,568
4Jun 23, 2024 16:304,93672,022,27823,958,00020,963,00092,164,096
5Jun 23, 2024 16:305,24277,910,60023,853,00023,853,00092,155,904
6Jun 23, 2024 16:305,57979,768,32423,893,00026,880,00092,233,728
7Jun 23, 2024 16:306,928124,325,58963,040,845092,528,640
8Jun 23, 2024 16:306,946131,590,51963,211,109092,520,448
9Jun 23, 2024 16:306,964133,310,59563,369,900092,659,712
10Jun 23, 2024 16:308,956112,939,78939,239,00042,257,00092,250,112
11Jun 23, 2024 16:309,045111,022,06336,138,00046,176,00092,250,112
12Jun 23, 2024 16:309,086107,586,73130,883,00051,804,00092,381,184