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 04:28Yuriy LyfenkoYuriy LyfenkoScore: 8,894Success
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 04:288,602141,654,90178,281,892094,781,440
2May 26, 2021 04:288,603184,270,69578,287,459094,748,672
3May 26, 2021 04:288,641152,322,84978,631,117094,679,040
4May 26, 2021 04:288,815105,877,81628,076,00052,142,00094,568,448
5May 26, 2021 04:288,864106,313,26031,867,00048,796,00094,629,888
6May 26, 2021 04:288,884103,916,59829,942,00050,901,00094,654,464
7May 26, 2021 04:288,894104,096,90236,969,00043,963,00094,703,616
8May 26, 2021 04:288,902105,696,98231,004,00050,007,00094,552,064
9May 26, 2021 04:288,903106,014,39835,006,00046,008,00094,584,832
10May 26, 2021 04:288,984112,993,06030,908,00050,848,00093,020,160
11May 26, 2021 04:289,026105,163,02738,063,00044,073,00093,040,640
12May 26, 2021 04:289,430112,195,14332,305,00053,506,00093,224,960