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 03:09Yuriy LyfenkoYuriy LyfenkoScore: 13,455Success
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 03:099,317155,957,90284,785,197094,760,960
2May 26, 2021 03:099,321140,612,86884,823,242094,748,672
3May 26, 2021 03:099,372176,069,82085,283,538094,785,536
4May 26, 2021 03:0913,418146,318,42069,061,00053,046,00094,785,536
5May 26, 2021 03:0913,425143,340,23771,100,00051,072,00094,687,232
6May 26, 2021 03:0913,444147,159,33874,204,00048,132,00094,572,544
7May 26, 2021 03:0913,455147,388,54680,291,00042,152,00094,789,632
8May 26, 2021 03:0913,455153,953,19277,281,00045,164,00094,732,288
9May 26, 2021 03:0913,481149,740,45074,805,00047,875,00094,625,792
10May 26, 2021 03:0913,482151,799,78271,817,00050,870,00093,069,312
11May 26, 2021 03:0913,486148,825,06674,833,00047,893,00094,564,352
12May 26, 2021 03:0913,719151,626,20178,900,00045,942,00093,212,672