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:31Yuriy LyfenkoYuriy LyfenkoScore: 14,505Success
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:318,560138,241,81177,893,418094,724,096
2May 26, 2021 04:318,560135,749,01077,895,186094,736,384
3May 26, 2021 04:318,711146,405,11979,271,101094,679,040
4May 26, 2021 04:3114,438160,662,17184,249,00047,139,00092,995,584
5May 26, 2021 04:3114,491155,830,77892,905,00038,960,00094,576,640
6May 26, 2021 04:3114,505156,729,10683,998,00047,999,00094,572,544
7May 26, 2021 04:3114,505159,709,06378,999,00052,999,00094,789,632
8May 26, 2021 04:3114,522159,541,88081,090,00051,056,00094,703,616
9May 26, 2021 04:3114,525158,039,96282,110,00050,067,00094,748,672
10May 26, 2021 04:3114,565158,485,31587,695,00044,844,00094,629,888
11May 26, 2021 04:3115,101164,893,17583,254,00054,165,00093,192,192
12May 26, 2021 04:3115,186163,720,60193,128,00045,062,00093,204,480