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 4, 2024 12:04NoSIMD_C#NoSIMD_C#Score: 1,066,943Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Dec 4, 2024 12:041,056,1729,645,470,4449,084,597,000526,570,00094,601,216
2Dec 4, 2024 12:041,061,3339,696,757,0109,141,656,000516,472,00094,617,600
3Dec 4, 2024 12:041,064,2789,721,036,3299,153,479,000531,447,00094,715,904
4Dec 4, 2024 12:041,066,8639,742,578,7799,181,969,000526,482,00094,576,640
5Dec 4, 2024 12:041,066,9439,745,694,2509,210,683,000498,495,00094,572,544
6Dec 4, 2024 12:041,067,4219,754,225,0749,162,011,000551,519,00094,617,600
7Dec 4, 2024 12:041,074,7559,816,884,9879,268,829,000511,438,00094,593,024
8Dec 4, 2024 12:041,082,0869,887,379,9219,302,424,000544,556,00094,556,160
9Dec 4, 2024 12:041,093,9209,992,173,1129,356,229,000598,439,00094,588,928