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 1, 2026 20:49A_ShamanA_ShamanScore: 62,784Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 1, 2026 20:5662,604579,571,864513,660,00056,041,000171,991,040
2Jul 1, 2026 20:5662,692580,161,251515,167,00055,336,000171,991,040
3Jul 1, 2026 20:5662,741580,485,986515,306,00055,641,000171,991,040
4Jul 1, 2026 20:5662,751581,012,494515,176,00055,860,000171,991,040
5Jul 1, 2026 20:5662,784580,954,440515,837,00055,503,000169,893,888
6Jul 1, 2026 20:5662,794581,343,637515,493,00055,933,000171,991,040
7Jul 1, 2026 20:5662,857581,886,684516,643,00055,358,000169,893,888
8Jul 1, 2026 20:5662,897582,243,407515,684,00056,679,000171,991,040
9Jul 1, 2026 20:5663,304585,995,209515,610,00060,464,000171,991,040