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 15:40Yuriy LyfenkoYuriy LyfenkoError
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 15:3100000exit with code 1: 309 52135 21121
2May 26, 2021 15:408,484141,323,02577,205,621094,687,232
3May 26, 2021 15:408,503154,107,97277,375,051094,760,960
4May 26, 2021 15:408,505135,681,61277,393,539094,740,480
5May 26, 2021 15:4014,173155,145,18080,985,00047,991,00094,625,792
6May 26, 2021 15:4014,186149,964,21180,057,00049,034,00094,564,352
7May 26, 2021 15:4014,197151,731,95486,127,00043,063,00094,572,544
8May 26, 2021 15:4014,212151,653,64074,188,00055,140,00094,752,768
9May 26, 2021 15:4014,227161,175,82185,305,00044,158,00093,052,928
10May 26, 2021 15:4014,231160,686,39181,316,00048,187,00094,588,928
11May 26, 2021 15:4014,570158,920,23788,393,00044,196,00094,552,064
12May 26, 2021 15:4014,635154,879,48680,110,00053,073,00093,110,272
13May 26, 2021 15:4014,808163,665,19979,855,00054,900,00093,224,960