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:45NoSIMD_C#NoSIMD_C#Score: 18,262Success
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:4518,155189,748,60953,067,000112,142,00092,672,000
2Dec 24, 2024 09:4518,241191,915,90558,998,000106,996,00092,487,680
3Dec 24, 2024 09:4518,249192,729,51556,021,000110,042,00092,581,888
4Dec 24, 2024 09:4518,252191,775,50259,034,000107,062,00092,590,080
5Dec 24, 2024 09:4518,262190,379,35859,065,000107,118,00092,532,736
6Dec 24, 2024 09:4518,294193,759,00859,811,000106,663,00092,577,792
7Dec 24, 2024 09:4518,333189,038,32554,943,000111,884,00092,446,720
8Dec 24, 2024 09:4518,417197,387,21950,877,000116,717,00092,450,816
9Dec 24, 2024 09:4518,425192,857,49861,876,000105,788,00092,696,576