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 listSep 16, 2026 13:11Victor MerckléVictor MerckléScore: 2,708Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 16, 2026 13:172,69733,307,19015,915,0008,635,00092,717,056stderr
2Sep 16, 2026 13:172,70133,423,06815,862,0008,718,00092,803,072stderr
3Sep 16, 2026 13:172,70733,411,56015,958,0008,679,00092,790,784stderr
4Sep 16, 2026 13:172,70733,333,29315,969,0008,670,00092,741,632stderr
5Sep 16, 2026 13:172,70833,345,22715,955,0008,695,00092,762,112stderr
6Sep 16, 2026 13:172,70833,405,18915,947,0008,697,00092,704,768stderr
7Sep 16, 2026 13:172,71233,424,32516,061,0008,623,00092,717,056stderr
8Sep 16, 2026 13:172,72033,466,45215,969,0008,788,00092,766,208stderr
9Sep 16, 2026 13:172,73933,655,20116,084,0008,842,00092,770,304stderr