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 19, 2026 17:48Victor MerckléVictor MerckléScore: 2,384Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 19, 2026 18:042,37329,941,06613,080,0008,521,00092,811,264stderr
2Aug 19, 2026 18:042,37329,887,68913,115,0008,484,00092,770,304stderr
3Aug 19, 2026 18:042,37729,986,57913,109,0008,522,00092,762,112stderr
4Aug 19, 2026 18:042,38430,736,67113,064,0008,638,00092,798,976stderr
5Aug 19, 2026 18:042,38430,097,23612,972,0008,727,00092,717,056stderr
6Aug 19, 2026 18:042,38930,529,77913,166,0008,577,00092,741,632stderr
7Aug 19, 2026 18:042,39131,982,61613,205,0008,557,00092,696,576stderr
8Aug 19, 2026 18:042,40738,828,63913,011,0008,897,00092,786,688stderr
9Aug 19, 2026 18:042,40930,294,11813,130,0008,800,00092,778,496stderr