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 18:13AnSaAnSaScore: 4,363Success
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 18:133,58359,160,35119,360,00013,246,00091,975,680
2Jun 23, 2024 18:133,59164,076,33019,805,00012,873,00091,901,952
3Jun 23, 2024 18:133,59769,477,58119,840,00012,896,00091,860,992
4Jun 23, 2024 18:133,60157,035,12420,854,00011,916,00091,889,664
5Jun 23, 2024 18:134,30666,707,84318,085,00021,099,00092,160,000
6Jun 23, 2024 18:134,35598,846,90639,631,223092,532,736
7Jun 23, 2024 18:134,363125,688,19239,707,820092,524,544
8Jun 23, 2024 18:134,393106,147,27739,978,675092,520,448
9Jun 23, 2024 18:134,68769,039,85619,837,00022,813,00092,143,616
10Jun 23, 2024 18:136,81589,271,95620,006,00042,013,00092,336,128
11Jun 23, 2024 18:138,175100,195,51927,144,00047,252,00092,246,016
12Jun 23, 2024 18:138,493107,565,61431,114,00046,169,00092,336,128