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 2, 2021 18:56Yuriy LyfenkoYuriy LyfenkoScore: 9,575Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 2, 2021 18:564,649597,865,48342,308,166094,658,560
2Jun 2, 2021 18:564,649605,759,63342,304,213094,654,464
3Jun 6, 2021 18:504,661599,491,65242,410,942094,658,560
4Jun 6, 2021 18:504,664602,142,60642,442,328094,662,656
5Jun 2, 2021 18:564,668600,911,91142,475,807094,658,560
6Jun 2, 2021 18:574,668594,172,78842,482,272094,658,560
7Jun 2, 2021 18:574,675597,426,27642,539,515094,650,368
8Jun 2, 2021 18:574,695598,641,24842,720,545094,662,656
9Jun 6, 2021 18:504,697602,084,24942,738,716094,662,656
10Jun 2, 2021 18:579,552615,671,95168,731,00018,193,00094,679,040
11Jun 6, 2021 18:509,562614,356,55469,812,00017,200,00094,547,968
12Jun 2, 2021 18:569,564609,552,39071,850,00015,179,00094,547,968
13Jun 6, 2021 18:509,564609,297,99072,867,00014,168,00094,547,968
14Jun 2, 2021 18:579,565611,048,73269,838,00017,206,00094,552,064
15Jun 6, 2021 18:509,572610,358,01070,088,00017,021,00094,547,968
16Jun 2, 2021 18:569,572614,674,13368,873,00018,231,00094,547,968
17Jun 2, 2021 18:579,573608,855,36672,935,00014,181,00094,547,968
18Jun 2, 2021 18:579,575609,584,65972,108,00015,022,00094,547,968
19Jun 2, 2021 18:579,575612,716,10071,936,00015,197,00094,547,968
20Jun 2, 2021 18:569,581610,107,29769,949,00017,234,00094,552,064
21Jun 2, 2021 18:569,585610,885,05971,186,00016,041,00094,547,968
22Jun 6, 2021 18:509,588614,264,75873,210,00014,040,00094,683,136
23Jun 2, 2021 18:579,590612,496,01671,220,00016,049,00094,547,968
24Jun 6, 2021 18:509,595617,972,87471,071,00016,244,00094,552,064
25Jun 2, 2021 18:569,610614,063,52369,358,00018,093,00092,979,200
26Jun 2, 2021 18:569,616612,118,19470,605,00016,905,00092,979,200
27Jun 6, 2021 18:509,623614,340,19270,455,00017,110,00094,547,968
28Jun 2, 2021 18:579,640612,565,35767,555,00020,165,00092,983,296
29Jun 2, 2021 18:569,647611,452,85370,631,00017,153,00094,552,064
30Jun 2, 2021 18:579,654607,500,78067,653,00020,195,00092,979,200
31Jun 2, 2021 18:579,798610,158,44071,127,00018,032,00093,245,440
32Jun 2, 2021 18:569,968625,170,66468,538,00022,174,00093,241,344
33Jun 6, 2021 18:509,969614,533,83371,565,00019,151,00093,241,344
34Jun 6, 2021 18:509,974616,177,48170,594,00020,169,00093,241,344
35Jun 2, 2021 18:5610,117615,532,39173,853,00018,210,00093,241,344
36Jun 6, 2021 18:5010,185620,974,72269,255,00023,424,00093,257,728