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 15:22Victor MerckléVictor MerckléError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 4, 2026 17:49Tomislav Tunkovic10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 4, 2026 17:56051,997,06036,820,0005,489,00051,675,136invalid character 's' looking for beginning of valuestderr
2Sep 4, 2026 17:56052,102,36536,793,0005,510,00051,666,944invalid character 's' looking for beginning of valuestderr
3Sep 4, 2026 17:56052,097,76436,805,0005,496,00051,691,520invalid character 's' looking for beginning of valuestderr
4Aug 19, 2026 15:302,52333,141,33413,859,0009,108,00092,790,784stderr
5Aug 19, 2026 15:302,53433,184,69614,004,0009,062,00092,745,728stderr
6Aug 19, 2026 15:302,53933,195,48614,103,0009,006,00092,717,056stderr
7Aug 19, 2026 15:302,54233,225,09413,916,0009,223,00092,794,880stderr
8Aug 19, 2026 15:302,54832,907,60314,326,0008,867,00092,803,072stderr
9Aug 19, 2026 15:302,54933,279,90214,214,0008,988,00092,827,648stderr
10Aug 19, 2026 15:302,55433,017,93913,991,0009,257,00092,758,016stderr
11Aug 19, 2026 15:302,55533,101,40514,324,0008,934,00092,778,496stderr
12Aug 19, 2026 15:302,55833,513,93114,336,0008,943,00092,762,112stderr