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:46Yuriy LyfenkoYuriy LyfenkoScore: 14,183Success
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:468,541133,046,10477,718,757094,748,672
2May 26, 2021 04:468,548137,604,17377,785,140094,728,192
3May 26, 2021 04:468,566136,134,06777,950,886094,695,424
4May 26, 2021 04:4614,155153,181,61282,878,00045,932,00094,760,960
5May 26, 2021 04:4614,169155,045,92380,959,00047,976,00094,789,632
6May 26, 2021 04:4614,174151,631,44278,988,00049,992,00094,642,176
7May 26, 2021 04:4614,183156,042,99284,043,00045,023,00094,633,984
8May 26, 2021 04:4614,195156,172,18579,109,00050,069,00094,777,344
9May 26, 2021 04:4614,206155,270,19580,173,00049,106,00094,552,064
10May 26, 2021 04:4614,254159,513,50481,817,00047,893,00094,781,440
11May 26, 2021 04:4614,305155,318,94685,115,00045,061,00093,106,176
12May 26, 2021 04:4614,759162,477,36180,181,00054,122,00093,110,272