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 28, 2021 00:25Yurkov AlekseyYurkov AlekseyScore: 12,805Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 28, 2021 00:256,084118,658,57855,364,850092,565,504
2May 28, 2021 00:256,103125,168,81855,534,912092,565,504
3May 28, 2021 00:256,198115,767,44456,403,074092,549,120
4May 28, 2021 00:2512,789141,904,049102,338,00014,046,00092,463,104
5May 28, 2021 00:2512,794148,151,893100,506,00015,921,00092,471,296
6May 28, 2021 00:2512,799142,330,899101,410,00015,060,00092,561,408
7May 28, 2021 00:2512,805142,387,612101,459,00015,068,00092,700,672
8May 28, 2021 00:2512,819146,302,99699,701,00016,949,00092,639,232
9May 28, 2021 00:2512,856145,668,95999,988,00016,998,00092,614,656
10May 28, 2021 00:2513,026148,371,658103,468,00015,068,00092,200,960
11May 28, 2021 00:2513,055146,573,33599,836,00018,968,00092,086,272
12May 28, 2021 00:2513,224143,451,90099,277,00021,058,00092,119,040