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 14:18AnSaAnSaScore: 7,660Success
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 14:184,85170,389,14532,102,00012,038,00092,139,520
2Jun 23, 2024 14:184,86371,702,67729,168,00015,087,00091,947,008
3Jun 23, 2024 14:184,89069,956,76131,351,00013,147,00091,906,048
4Jun 23, 2024 14:184,90970,271,29629,784,00014,892,00091,881,472
5Jun 23, 2024 14:184,91175,146,01733,765,00010,924,00091,897,856
6Jun 23, 2024 14:185,84780,975,62232,125,00021,082,00092,168,192
7Jun 23, 2024 14:187,660138,842,00369,708,945092,528,640
8Jun 23, 2024 14:187,672118,278,92469,810,748092,536,832
9Jun 23, 2024 14:187,672130,496,55169,813,165092,532,736
10Jun 23, 2024 14:187,772100,761,96932,873,00037,854,00092,340,224
11Jun 23, 2024 14:188,274106,935,22236,139,00039,151,00092,303,360
12Jun 23, 2024 14:1810,098119,438,62250,940,00040,952,00092,327,936