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 06:55Yuriy LyfenkoYuriy LyfenkoScore: 14,175Success
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 06:558,504137,251,89177,390,269094,724,096
2May 26, 2021 06:558,553132,199,22577,836,240094,789,632
3May 26, 2021 06:558,561141,487,51777,901,978094,769,152
4May 26, 2021 06:5514,161156,506,70486,909,00041,956,00094,576,640
5May 26, 2021 06:5514,169150,744,09379,962,00048,976,00094,601,216
6May 26, 2021 06:5514,175157,071,02286,994,00041,997,00094,674,944
7May 26, 2021 06:5514,175158,071,77289,995,00038,997,00094,576,640
8May 26, 2021 06:5514,182157,623,14683,037,00046,020,00094,707,712
9May 26, 2021 06:5514,204152,138,83490,178,00039,077,00092,925,952
10May 26, 2021 06:5514,212150,586,23284,217,00045,116,00094,605,312
11May 26, 2021 06:5514,216150,489,60784,241,00045,129,00092,975,104
12May 26, 2021 06:5514,517155,051,16681,066,00051,042,00093,011,968