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 listJun 6, 2021 19:00Yuriy LyfenkoYuriy LyfenkoScore: 9,589Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 6, 2021 19:004,666605,146,28942,463,907094,662,656
2Jun 6, 2021 19:004,669603,829,80442,488,972094,662,656
3Jun 6, 2021 19:004,672597,949,40542,518,057094,654,464
4Jun 6, 2021 19:009,553611,516,37568,946,00017,986,00094,547,968
5Jun 6, 2021 19:009,569609,030,15970,881,00016,201,00094,552,064
6Jun 6, 2021 19:009,579608,449,31670,950,00016,217,00094,670,848
7Jun 6, 2021 19:009,589611,895,59268,201,00019,056,00094,683,136
8Jun 6, 2021 19:009,593621,355,98271,052,00016,240,00094,547,968
9Jun 6, 2021 19:009,622618,780,04272,467,00015,097,00094,547,968
10Jun 6, 2021 19:009,885615,046,79472,768,00017,181,00093,237,248
11Jun 6, 2021 19:009,926616,894,14266,982,00023,342,00093,241,344
12Jun 6, 2021 19:0010,035612,566,82573,052,00018,263,00093,241,344