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 listDec 9, 2024 11:32NoSIMD_C#NoSIMD_C#Score: 18,426Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Dec 13, 2024 07:5718,153189,106,42654,063,000111,131,00092,577,792
2Dec 9, 2024 11:3218,259192,230,20856,052,000110,103,00092,622,848
3Dec 13, 2024 07:5718,337190,843,57760,950,000105,913,00092,688,384
4Dec 9, 2024 11:3218,349190,045,88156,992,000109,986,00092,643,328
5Dec 9, 2024 11:3218,380194,705,28752,079,000115,176,00092,450,816
6Dec 9, 2024 11:3218,381195,052,62262,098,000105,167,00092,602,368
7Dec 9, 2024 11:3218,426193,918,64661,880,000105,795,00092,573,696
8Dec 9, 2024 11:3218,436192,944,62757,920,000109,848,00092,667,904
9Dec 9, 2024 11:3218,445196,084,43558,949,000108,905,00092,610,560
10Dec 13, 2024 07:5718,471198,134,59960,029,000108,053,00092,524,544
11Dec 9, 2024 11:3218,480190,604,93159,060,000109,111,00092,692,480
12Dec 9, 2024 11:3218,512196,103,96152,830,000115,629,00092,598,272