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 10:11Victor MerckléVictor MerckléScore: 2,620Success
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 10:172,60432,790,15714,965,0008,738,00092,774,400stderr
2Aug 19, 2026 10:172,61132,782,01714,998,0008,763,00092,745,728stderr
3Aug 19, 2026 10:172,61532,237,43215,031,0008,773,00092,774,400stderr
4Aug 19, 2026 10:172,62032,367,11915,097,0008,752,00092,725,248stderr
5Aug 19, 2026 10:172,62032,919,42215,065,0008,779,00092,786,688stderr
6Aug 19, 2026 10:172,62732,907,22015,096,0008,816,00092,725,248stderr
7Aug 19, 2026 10:172,63633,047,88915,142,0008,848,00092,725,248stderr
8Aug 19, 2026 10:172,63732,956,22415,103,0008,894,00092,762,112stderr
9Aug 19, 2026 10:172,64032,316,13215,149,0008,878,00092,766,208stderr