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 09:14Victor MerckléVictor MerckléScore: 2,608Success
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 09:202,60132,773,87914,932,0008,743,00092,766,208stderr
2Aug 19, 2026 09:202,60532,767,06414,944,0008,764,00092,737,536stderr
3Aug 19, 2026 09:202,60632,833,37214,961,0008,759,00092,749,824stderr
4Aug 19, 2026 09:202,60732,799,60214,962,0008,765,00092,708,864stderr
5Aug 19, 2026 09:202,60832,727,53415,003,0008,734,00092,749,824stderr
6Aug 19, 2026 09:202,60832,016,00914,982,0008,751,00092,745,728stderr
7Aug 19, 2026 09:202,62032,931,91614,996,0008,848,00092,770,304stderr
8Aug 19, 2026 09:202,62233,010,42715,011,0008,858,00092,696,576stderr
9Aug 19, 2026 09:202,62832,287,71815,057,0008,865,00092,753,920stderr