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 7, 2026 04:23Victor MerckléVictor MerckléScore: 2,672Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 7, 2026 04:312,63832,038,87415,363,0008,648,00092,766,208stderr
2Jul 7, 2026 04:312,65432,346,56815,404,0008,751,00092,753,920stderr
3Jul 7, 2026 04:312,65732,128,33315,346,0008,837,00092,721,152stderr
4Jul 7, 2026 04:312,67032,440,26615,485,0008,816,00092,762,112stderr
5Jul 7, 2026 04:312,67232,269,46115,407,0008,910,00092,741,632stderr
6Jul 7, 2026 04:312,69538,295,28015,543,0008,990,00092,782,592stderr
7Jul 7, 2026 04:312,69932,588,53515,699,0008,866,00092,770,304stderr
8Jul 7, 2026 04:312,70232,576,86115,596,0008,996,00092,745,728stderr
9Jul 7, 2026 04:312,75833,029,90816,204,0008,901,00092,741,632stderr