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 24, 2024 09:42NoSIMD_C#NoSIMD_C#Score: 18,294Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Dec 24, 2024 09:4218,013191,484,85757,970,000105,945,00092,700,672
2Dec 24, 2024 09:4218,206192,618,49252,896,000112,780,00092,602,368
3Dec 24, 2024 09:4218,235189,078,08552,980,000112,957,00092,684,288
4Dec 24, 2024 09:4218,259192,093,75354,050,000112,103,00092,655,616
5Dec 24, 2024 09:4218,294187,364,25651,837,000114,640,00092,573,696
6Dec 24, 2024 09:4218,331193,820,04956,935,000109,875,00092,463,104
7Dec 24, 2024 09:4218,352190,545,39754,002,000113,004,00092,454,912
8Dec 24, 2024 09:4218,440192,047,09455,935,000111,871,00092,622,848
9Dec 24, 2024 09:4218,474191,214,24060,042,000108,075,00092,450,816