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 listJul 28, 2023 22:46Yurkov AlekseyYurkov AlekseyScore: 16,254Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 28, 2023 22:469,144145,725,34383,206,110092,569,600
2Jul 28, 2023 22:469,149163,856,32583,251,809092,692,480
3Jul 28, 2023 22:469,186146,103,58983,597,146092,573,696
4Jul 28, 2023 22:4616,206176,630,636103,336,00044,143,00092,536,832
5Jul 28, 2023 22:4616,211177,652,225107,377,00040,141,00092,524,544
6Jul 28, 2023 22:4616,220171,867,201105,713,00041,886,00092,446,720
7Jul 28, 2023 22:4616,254171,350,724106,938,00040,976,00092,651,520
8Jul 28, 2023 22:4616,258170,952,872108,962,00038,986,00092,585,984
9Jul 28, 2023 22:4616,343179,406,108102,809,00045,914,00092,053,504
10Jul 28, 2023 22:4616,420174,774,898108,307,00041,116,00092,618,752
11Jul 28, 2023 22:4616,451175,347,595105,791,00043,913,00092,581,888
12Jul 28, 2023 22:4616,570173,362,753108,847,00041,941,00092,274,688