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 13:52Victor MerckléVictor MerckléError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Oct 31, 2026 13:23Andrew Epstein10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Oct 31, 2026 13:30087,465,53664,635,00013,170,00066,543,616invalid character ',' looking for beginning of valuestderr
2Oct 31, 2026 13:300103,731,41572,367,00021,734,00066,494,464invalid character ',' looking for beginning of valuestderr
3Oct 31, 2026 13:300103,649,61972,276,00021,721,00066,465,792invalid character ',' looking for beginning of valuestderr
4Aug 19, 2026 13:582,39030,935,21013,045,0008,706,00092,782,592stderr
5Aug 19, 2026 13:582,39430,933,60313,002,0008,785,00092,782,592stderr
6Aug 19, 2026 13:582,39830,933,85913,045,0008,781,00092,762,112stderr
7Aug 19, 2026 13:582,40030,841,77313,126,0008,721,00092,770,304stderr
8Aug 19, 2026 13:582,40430,903,89513,160,0008,719,00092,774,400stderr
9Aug 19, 2026 13:582,40630,918,32513,187,0008,710,00092,745,728stderr
10Aug 19, 2026 13:582,41631,050,78013,070,0008,923,00092,794,880stderr
11Aug 19, 2026 13:582,43331,137,62813,129,0009,013,00092,700,672stderr
12Aug 19, 2026 13:582,43431,186,75513,118,0009,035,00092,733,440stderr