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 5, 2026 03:03olliecrowolliecrowScore: 4,179Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 5, 2026 03:094,15954,617,54921,175,00016,672,00094,666,752
2May 5, 2026 03:094,16454,037,10121,147,00016,751,00094,666,752
3May 5, 2026 03:094,16454,826,81221,232,00016,665,00094,670,848
4May 5, 2026 03:094,17354,756,92521,291,00016,691,00094,666,752
5May 5, 2026 03:094,17955,971,27421,194,00016,835,00094,658,560
6May 5, 2026 03:094,19058,173,29221,245,00016,887,00094,662,656
7May 5, 2026 03:094,19957,677,64321,319,00016,896,00094,658,560
8May 5, 2026 03:094,20355,305,89521,216,00017,036,00094,666,752
9May 5, 2026 03:094,20854,683,01621,209,00017,087,00094,662,656