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:06Yurkov AlekseyYurkov AlekseyScore: 12,757Success
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:065,893130,158,03753,627,900092,561,408
2May 28, 2021 01:065,896126,463,34053,656,747092,565,504
3May 28, 2021 01:066,030135,967,59054,874,219092,565,504
4May 28, 2021 01:0612,719138,681,37396,787,00018,958,00092,700,672
5May 28, 2021 01:0612,729136,299,37697,858,00017,973,00092,463,104
6May 28, 2021 01:0612,747139,238,30398,002,00018,000,00092,471,296
7May 28, 2021 01:0612,757139,207,502101,074,00015,011,00092,463,104
8May 28, 2021 01:0612,770147,570,68996,171,00020,035,00092,471,296
9May 28, 2021 01:0612,779142,229,07995,236,00021,052,00092,463,104
10May 28, 2021 01:0612,780138,963,20199,251,00017,043,00092,471,296
11May 28, 2021 01:0612,783138,839,741101,285,00015,042,00092,639,232
12May 28, 2021 01:0613,004137,642,102101,285,00017,047,00092,041,216