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:05Yurkov AlekseyYurkov AlekseyScore: 12,947Success
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:056,256119,738,04456,926,996092,569,600
2May 28, 2021 01:056,277113,556,76857,123,462092,577,792
3May 28, 2021 01:056,295119,930,12457,286,529092,561,408
4May 28, 2021 01:0512,919144,327,18699,627,00017,932,00092,635,136
5May 28, 2021 01:0512,924148,008,76698,668,00018,936,00092,667,904
6May 28, 2021 01:0512,938139,920,06098,779,00018,957,00092,635,136
7May 28, 2021 01:0512,947138,870,42198,846,00018,970,00092,450,816
8May 28, 2021 01:0512,948140,120,26099,850,00017,973,00092,471,296
9May 28, 2021 01:0512,956143,244,309100,914,00016,985,00092,450,816
10May 28, 2021 01:0512,973145,999,490100,044,00018,008,00092,528,640
11May 28, 2021 01:0513,048148,138,544100,775,00017,959,00092,180,480
12May 28, 2021 01:0513,265146,866,494100,762,00019,952,00092,180,480