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 02:42Yuriy LyfenkoYuriy LyfenkoScore: 13,934Success
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 02:4210,924155,932,64499,407,076094,679,040
2May 26, 2021 02:4210,939155,483,24899,543,295094,773,248
3May 26, 2021 02:4210,973161,190,70099,858,780094,773,248
4May 26, 2021 02:4213,894151,432,86478,272,00048,167,00094,547,968
5May 26, 2021 02:4213,896157,568,55278,280,00048,172,00094,711,808
6May 26, 2021 02:4213,928155,730,10677,845,00048,903,00094,785,536
7May 26, 2021 02:4213,934153,872,10782,871,00043,931,00094,547,968
8May 26, 2021 02:4213,938147,435,16371,907,00054,929,00094,785,536
9May 26, 2021 02:4213,938154,135,28482,894,00043,944,00094,629,888
10May 26, 2021 02:4213,955150,940,18381,991,00044,995,00093,011,968
11May 26, 2021 02:4214,021149,650,67675,756,00051,833,00093,097,984
12May 26, 2021 02:4214,197152,117,55471,108,00058,088,00092,962,816