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 22, 2024 00:32Joad NacerJoad NacerScore: 3,656Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 22, 2024 00:323,43359,892,07420,157,00011,086,00092,913,664
2May 22, 2024 00:323,44658,404,23421,241,00010,114,00093,184,000
3May 22, 2024 00:323,46252,774,52021,344,00010,164,00092,868,608
4May 22, 2024 00:323,53060,108,48120,075,00012,045,00093,167,616
5May 22, 2024 00:323,642100,426,83433,143,008094,490,624
6May 22, 2024 00:323,65585,611,07333,263,477094,748,672
7May 22, 2024 00:323,65694,119,85333,270,263094,482,432
8May 22, 2024 00:323,89056,775,04921,242,00014,161,00093,122,560
9May 22, 2024 00:324,16165,704,90420,926,00016,940,00093,097,984
10May 22, 2024 00:327,433103,658,75425,240,00042,403,00093,167,616
11May 22, 2024 00:327,44896,663,35425,916,00041,865,00093,270,016
12May 22, 2024 00:327,50898,061,01024,114,00044,209,00093,364,224