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 28, 2021 01:02Yurkov AlekseyYurkov AlekseyScore: 12,935Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 28, 2021 01:026,248118,559,06156,859,723092,569,600
2May 28, 2021 01:026,248135,422,00056,855,770092,561,408
3May 28, 2021 01:026,259113,038,21756,959,050092,577,792
4May 28, 2021 01:0212,906143,345,298100,384,00017,065,00092,446,720
5May 28, 2021 01:0212,907143,135,42298,546,00018,912,00092,704,768
6May 28, 2021 01:0212,930143,839,446100,714,00016,952,00092,471,296
7May 28, 2021 01:0212,935143,716,53999,750,00017,955,00092,463,104
8May 28, 2021 01:0212,936144,460,560102,626,00015,092,00092,446,720
9May 28, 2021 01:0212,969141,001,372100,015,00018,002,00092,549,120
10May 28, 2021 01:0212,981142,441,211100,109,00018,019,00091,926,528
11May 28, 2021 01:0213,014144,416,237100,360,00018,064,00092,041,216
12May 28, 2021 01:0213,254149,459,457102,668,00017,941,00092,192,768