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 30, 2024 03:49Mikhail ShirokovMikhail ShirokovScore: 107,806Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Dec 30, 2024 03:49107,1741,144,397,861637,876,000337,405,000108,314,624
2Dec 30, 2024 03:49107,4861,151,816,011650,081,000328,040,000107,974,656
3Dec 30, 2024 03:49107,5671,169,550,292638,213,000340,647,000108,933,120
4Dec 30, 2024 03:49107,6311,165,755,807645,993,000333,448,000108,646,400
5Dec 30, 2024 03:49107,8061,154,046,739634,379,000346,660,000107,909,120
6Dec 30, 2024 03:49107,8181,156,969,949634,801,000346,346,000108,548,096
7Dec 30, 2024 03:49108,7171,153,100,771640,211,000349,115,000108,441,600
8Dec 30, 2024 03:49109,3781,166,851,487658,225,000337,115,000108,568,576
9Dec 30, 2024 03:49110,5111,185,490,360640,867,000364,786,000108,998,656