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 08:10Victor MerckléVictor MerckléError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 5, 2026 03:01Tomislav Tunkovic10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 5, 2026 04:29051,789,58236,671,0004,515,00051,691,520invalid character 'o' looking for beginning of valuestderr
2Sep 5, 2026 04:29050,366,89236,881,0004,402,00051,675,136invalid character '>' in literal true (expecting 'r')stderr
3Sep 5, 2026 04:29049,698,40136,739,0004,457,00051,712,000invalid character 's' looking for beginning of valuestderr
4Aug 19, 2026 08:172,61932,427,90315,006,0008,830,00092,704,768stderr
5Aug 19, 2026 08:172,62332,842,48815,119,0008,757,00092,721,152stderr
6Aug 19, 2026 08:172,62732,896,56615,149,0008,758,00092,712,960stderr
7Aug 19, 2026 08:172,62832,933,09815,155,0008,767,00092,762,112stderr
8Aug 19, 2026 08:172,63332,992,31915,138,0008,823,00092,790,784stderr
9Aug 19, 2026 08:172,63732,955,42315,190,0008,811,00092,704,768stderr
10Aug 19, 2026 08:172,63732,461,50615,152,0008,846,00092,733,440stderr
11Aug 19, 2026 08:172,63932,218,14415,142,0008,875,00092,717,056stderr
12Aug 19, 2026 08:172,64233,099,61715,239,0008,805,00092,737,536stderr