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 listAug 18, 2026 14:49Victor MerckléVictor MerckléScore: 2,772Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 18, 2026 14:552,74234,862,98316,248,0008,708,00092,741,632stderr
2Aug 18, 2026 14:552,76034,990,72416,356,0008,769,00092,753,920stderr
3Aug 18, 2026 14:552,76835,136,51516,371,0008,826,00092,712,960stderr
4Aug 18, 2026 14:552,77135,008,87616,444,0008,779,00092,729,344stderr
5Aug 18, 2026 14:552,77235,035,79616,426,0008,808,00092,741,632stderr
6Aug 18, 2026 14:552,77835,066,12116,451,0008,830,00092,737,536stderr
7Aug 18, 2026 14:552,79135,162,80116,710,0008,697,00092,692,480stderr
8Aug 18, 2026 14:552,79335,257,28216,785,0008,634,00092,733,440stderr
9Aug 18, 2026 14:552,79935,278,81516,765,0008,706,00092,708,864stderr