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 10:02NoSIMD_C#NoSIMD_C#Score: 18,385Success
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 10:0218,254192,969,20064,043,000102,069,00092,692,480
2Dec 24, 2024 10:0218,320189,178,74358,898,000107,814,00092,692,480
3Dec 24, 2024 10:0218,323199,257,96158,908,000107,832,00092,692,480
4Dec 24, 2024 10:0218,358189,470,80056,018,000111,037,00092,704,768
5Dec 24, 2024 10:0218,385192,933,56151,092,000116,209,00092,442,624
6Dec 24, 2024 10:0218,397193,736,43647,832,000119,580,00092,700,672
7Dec 24, 2024 10:0218,423197,952,49159,873,000107,772,00092,659,712
8Dec 24, 2024 10:0218,449187,835,40159,958,000107,925,00092,684,288
9Dec 24, 2024 10:0218,624195,990,16858,820,000110,661,00092,545,024