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 listJun 6, 2021 18:57Yuriy LyfenkoYuriy LyfenkoScore: 9,620Success
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 6, 2021 18:574,671598,648,33242,509,636094,662,656
2Jun 6, 2021 18:574,702612,535,17342,786,182094,658,560
3Jun 6, 2021 18:574,703601,762,18442,800,437094,662,656
4Jun 6, 2021 18:579,568609,598,80770,873,00016,199,00094,547,968
5Jun 6, 2021 18:579,586614,913,16272,022,00015,215,00094,547,968
6Jun 6, 2021 18:579,612609,248,03571,384,00016,086,00094,670,848
7Jun 6, 2021 18:579,620623,230,44570,435,00017,105,00094,547,968
8Jun 6, 2021 18:579,649612,300,92768,633,00019,176,00094,679,040
9Jun 6, 2021 18:579,650612,828,21271,664,00016,149,00094,683,136
10Jun 6, 2021 18:579,786615,659,31670,839,00018,215,00093,241,344
11Jun 6, 2021 18:579,838618,550,15971,417,00018,105,00092,975,104
12Jun 6, 2021 18:579,849614,225,02869,485,00020,140,00092,975,104