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 19:07Yurkov AlekseyYurkov AlekseyScore: 14,023Success
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 19:0710,374164,013,60894,402,234092,553,216
2May 26, 2021 19:0710,382206,224,18494,480,176092,553,216
3May 26, 2021 19:0710,552153,369,84796,023,283092,557,312
4May 26, 2021 19:0713,960150,833,112110,035,00017,005,00092,463,104
5May 26, 2021 19:0713,962153,224,815109,050,00018,008,00092,450,816
6May 26, 2021 19:0714,003155,033,936112,377,00015,050,00092,446,720
7May 26, 2021 19:0714,023156,163,187114,545,00013,062,00092,450,816
8May 26, 2021 19:0714,028152,655,741110,702,00016,954,00092,700,672
9May 26, 2021 19:0714,061152,121,223111,963,00015,994,00092,192,768
10May 26, 2021 19:0714,177153,531,461117,009,00012,001,00092,155,904
11May 26, 2021 19:0714,305160,043,770110,149,00020,027,00092,270,592
12May 26, 2021 19:0714,562152,580,915118,457,00014,054,00092,213,248