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éError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Oct 31, 2026 14:50Andrew Epstein10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Oct 31, 2026 15:16074,784,54058,817,0006,358,00066,285,568invalid character ',' looking for beginning of valuestderr
2Oct 31, 2026 15:16074,857,21359,742,0005,405,00066,428,928invalid character ',' looking for beginning of valuestderr
3Oct 31, 2026 15:16074,856,42159,744,0005,483,00066,437,120invalid character ',' looking for beginning of valuestderr
4Aug 19, 2026 09:202,60132,773,87914,932,0008,743,00092,766,208stderr
5Aug 19, 2026 09:202,60532,767,06414,944,0008,764,00092,737,536stderr
6Aug 19, 2026 09:202,60632,833,37214,961,0008,759,00092,749,824stderr
7Aug 19, 2026 09:202,60732,799,60214,962,0008,765,00092,708,864stderr
8Aug 19, 2026 09:202,60832,727,53415,003,0008,734,00092,749,824stderr
9Aug 19, 2026 09:202,60832,016,00914,982,0008,751,00092,745,728stderr
10Aug 19, 2026 09:202,62032,931,91614,996,0008,848,00092,770,304stderr
11Aug 19, 2026 09:202,62233,010,42715,011,0008,858,00092,696,576stderr
12Aug 19, 2026 09:202,62832,287,71815,057,0008,865,00092,753,920stderr