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 11, 2026 17:35Victor MerckléVictor MerckléScore: 2,719Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 11, 2026 17:412,70733,737,91815,925,0008,711,00092,729,344
2Jun 11, 2026 17:412,70733,664,79015,942,0008,698,00092,712,960
3Jun 11, 2026 17:412,71833,704,21616,000,0008,734,00092,696,576
4Jun 11, 2026 17:412,71833,711,36915,968,0008,773,00092,729,344
5Jun 11, 2026 17:412,71933,754,93215,996,0008,750,00092,721,152
6Jun 11, 2026 17:412,72235,097,99715,975,0008,798,00092,766,208
7Jun 11, 2026 17:412,72633,871,52215,809,0009,003,00092,729,344
8Jun 11, 2026 17:412,72833,825,60416,042,0008,783,00092,774,400
9Jun 11, 2026 17:412,74033,884,24616,090,0008,846,00092,737,536