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:49Yuriy LyfenkoYuriy LyfenkoScore: 12,958Success
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:498,731140,318,66579,448,346094,773,248
2May 26, 2021 03:498,756140,298,86379,677,926094,683,136
3May 26, 2021 03:498,766142,949,76879,770,659094,789,632
4May 26, 2021 03:4912,937141,834,56967,842,00049,884,00094,773,248
5May 26, 2021 03:4912,945142,582,22465,889,00051,913,00094,568,448
6May 26, 2021 03:4912,946141,744,08972,496,00045,310,00094,687,232
7May 26, 2021 03:4912,958145,860,33664,957,00052,965,00094,760,960
8May 26, 2021 03:4912,964143,275,72869,985,00047,989,00094,556,160
9May 26, 2021 03:4912,994140,932,68373,153,00045,094,00094,666,752
10May 26, 2021 03:4913,392145,010,81767,928,00053,943,00093,216,768
11May 26, 2021 03:4913,473153,234,31871,354,00051,254,00093,020,160
12May 26, 2021 03:4913,654146,809,10970,144,00054,111,00093,261,824