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 31, 2024 06:32Mikhail ShirokovMikhail ShirokovScore: 27,126Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Dec 31, 2024 06:3226,944270,570,006198,155,00047,036,000105,246,720
2Dec 31, 2024 06:3227,050270,914,130193,121,00053,033,000105,283,584
3Dec 31, 2024 06:3227,100277,259,131188,700,00057,907,000105,213,952
4Dec 31, 2024 06:3227,100271,969,427192,696,00053,915,000105,218,048
5Dec 31, 2024 06:3227,126276,038,990191,882,00054,966,000105,259,008
6Dec 31, 2024 06:3227,135275,377,669189,944,00056,983,000105,037,824
7Dec 31, 2024 06:3227,141278,755,388197,990,00048,997,000105,140,224
8Dec 31, 2024 06:3227,142276,840,806193,993,00052,998,000105,033,728
9Dec 31, 2024 06:3227,173280,255,553196,219,00051,057,000105,103,360