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 listMay 26, 2021 18:53Yurkov AlekseyYurkov AlekseyScore: 14,312Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 26, 2021 18:5310,604178,171,74596,498,667092,573,696
2May 26, 2021 18:5310,637171,365,07996,794,675092,565,504
3May 26, 2021 18:5310,666168,733,24997,058,291092,569,600
4May 26, 2021 18:5314,290154,613,782114,037,00016,005,00092,450,816
5May 26, 2021 18:5314,300152,281,691116,118,00014,014,00092,450,816
6May 26, 2021 18:5314,301154,712,380113,125,00017,018,00092,704,768
7May 26, 2021 18:5314,312157,715,763116,215,00014,026,00092,450,816
8May 26, 2021 18:5314,315151,018,777116,242,00014,029,00092,708,864
9May 26, 2021 18:5314,322157,293,748117,299,00013,033,00092,450,816
10May 26, 2021 18:5314,445160,250,543113,388,00018,061,00092,078,080
11May 26, 2021 18:5314,501154,687,009117,966,00013,996,00092,151,808
12May 26, 2021 18:5314,767158,505,379115,329,00019,054,00092,188,672