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 listAug 8, 2022 17:29Eugene ZhydzetskiEugene ZhydzetskiScore: 1,102,450Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 8, 2022 16:501,092,77110,001,531,0279,944,216,830094,793,728
2Aug 8, 2022 17:291,093,31710,024,175,7809,949,182,350094,736,384
3Aug 8, 2022 16:501,102,31510,087,292,55610,031,068,722094,740,480
4Aug 8, 2022 17:291,102,45010,096,651,83510,032,291,880094,732,288
5Aug 8, 2022 17:291,104,23710,108,183,63810,048,555,873094,744,576
6Aug 8, 2022 16:501,108,34710,151,905,12310,085,955,951094,801,920