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 29, 2021 14:43Yuriy LyfenkoYuriy LyfenkoScore: 14,214Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 29, 2021 14:438,522138,978,37277,548,772094,695,424
2May 29, 2021 14:438,559133,162,52977,887,273094,793,728
3May 29, 2021 14:438,608144,464,88978,335,161094,744,576
4May 29, 2021 14:4314,184158,470,80887,047,00042,023,00094,748,672
5May 29, 2021 14:4314,192151,150,59282,096,00047,055,00094,609,408
6May 29, 2021 14:4314,202155,719,02286,161,00043,080,00094,547,968
7May 29, 2021 14:4314,214157,653,46684,227,00045,121,00094,781,440
8May 29, 2021 14:4314,223158,761,79779,262,00050,166,00093,196,288
9May 29, 2021 14:4314,225155,486,19769,701,00059,743,00094,625,792
10May 29, 2021 14:4314,255159,231,57483,819,00045,901,00094,609,408
11May 29, 2021 14:4314,812154,248,12880,873,00053,915,00093,143,040
12May 29, 2021 14:4314,919165,701,94176,867,00058,898,00093,167,616