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 15:08Mikhail ShirokovMikhail ShirokovScore: 58,148Success
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 15:0857,889555,624,756423,831,000102,958,000111,513,600
2Dec 30, 2024 15:0857,953553,479,118436,483,00090,892,000111,529,984
3Dec 30, 2024 15:0857,998551,888,605433,820,00093,961,000111,550,464
4Dec 30, 2024 15:0858,112555,502,795435,851,00092,968,000111,366,144
5Dec 30, 2024 15:0858,148553,185,950436,125,00093,026,000111,325,184
6Dec 30, 2024 15:0858,167555,008,075442,431,00086,888,000111,562,752
7Dec 30, 2024 15:0858,264561,814,572433,348,00096,854,000111,501,312
8Dec 30, 2024 15:0858,857564,393,422443,666,00091,930,000111,566,848
9Dec 30, 2024 15:0863,455599,641,217484,534,00092,910,000111,345,664