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 listJul 17, 2021 10:30Yurkov AlekseyYurkov AlekseyScore: 14,208Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 17, 2021 10:307,166122,855,66965,213,617092,569,600
2Jul 17, 2021 10:307,195135,213,27765,471,288092,565,504
3Jul 17, 2021 10:307,202125,444,96165,538,236092,569,600
4Jul 17, 2021 10:3014,195153,656,726107,146,00022,030,00092,471,296
5Jul 17, 2021 10:3014,208157,229,850108,246,00021,047,00092,704,768
6Jul 17, 2021 10:3014,208158,143,481110,250,00019,043,00092,712,960
7Jul 17, 2021 10:3014,208155,298,056104,240,00025,057,00092,471,296
8Jul 17, 2021 10:3014,211152,563,078110,271,00019,046,00092,471,296
9Jul 17, 2021 10:3014,234157,732,01397,648,00031,885,00092,450,816
10Jul 17, 2021 10:3014,235157,981,369105,441,00024,101,00092,471,296
11Jul 17, 2021 10:3014,394158,596,919107,988,00022,997,00092,205,056
12Jul 17, 2021 10:3014,404163,174,134107,066,00024,014,00091,942,912