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:27Yuriy LyfenkoYuriy LyfenkoScore: 9,579Success
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:274,724108,596,97642,988,780094,658,560
2May 26, 2021 19:274,72798,610,04843,015,199094,654,464
3May 26, 2021 19:274,862128,910,32144,242,127094,662,656
4May 26, 2021 19:279,552115,647,50269,937,00016,984,00094,552,064
5May 26, 2021 19:279,562111,145,27572,009,00015,001,00094,679,040
6May 26, 2021 19:279,573112,602,01672,094,00015,019,00094,679,040
7May 26, 2021 19:279,579110,492,59871,135,00016,030,00094,674,944
8May 26, 2021 19:279,604111,612,62370,510,00016,882,00094,547,968
9May 26, 2021 19:279,663108,807,92570,946,00016,987,00094,552,064
10May 26, 2021 19:279,929114,160,78770,276,00020,078,00093,241,344
11May 26, 2021 19:279,952115,089,84170,435,00020,124,00093,245,440
12May 26, 2021 19:279,959113,171,93766,725,00023,901,00092,979,200