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:32Victor MerckléVictor MerckléScore: 2,407Success
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 17:432,39730,323,48013,114,0008,707,00092,786,688stderr
2Aug 19, 2026 17:432,39730,862,65513,132,0008,682,00092,704,768stderr
3Aug 19, 2026 17:432,40231,147,49913,291,0008,572,00092,827,648stderr
4Aug 19, 2026 17:432,40730,936,84713,314,0008,594,00092,786,688stderr
5Aug 19, 2026 17:432,40730,900,17613,110,0008,802,00092,753,920stderr
6Aug 19, 2026 17:432,40830,195,98513,184,0008,731,00092,741,632stderr
7Aug 19, 2026 17:432,41130,485,18113,018,0008,929,00092,766,208stderr
8Aug 19, 2026 17:432,41432,785,83613,059,0008,911,00092,708,864stderr
9Aug 19, 2026 17:432,42239,234,01113,406,0008,643,00092,819,456stderr