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 listJun 11, 2026 01:30Victor MerckléVictor MerckléError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 4, 2026 19:47Tomislav Tunkovic10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 4, 2026 19:51023,166,5798,760,0004,546,00041,873,408invalid character 'r' looking for beginning of value
2Sep 4, 2026 19:51023,562,0188,770,0004,570,00041,861,120invalid character 's' looking for beginning of value
3Sep 4, 2026 19:51023,147,6658,701,0004,679,00041,828,352invalid character '<' after object key:value pair
4Jun 11, 2026 01:382,83835,058,41416,917,0008,915,00092,815,360
5Jun 11, 2026 01:382,85434,923,62017,224,0008,756,00092,745,728
6Jun 11, 2026 01:382,85534,966,40017,058,0008,923,00092,823,552
7Jun 11, 2026 01:382,86235,069,41017,083,0008,970,00092,786,688
8Jun 11, 2026 01:382,86435,888,39117,075,0008,989,00092,839,936
9Jun 11, 2026 01:382,86535,241,75617,072,0009,006,00092,749,824
10Jun 11, 2026 01:382,87235,076,05317,122,0009,014,00092,733,440
11Jun 11, 2026 01:382,88236,779,94117,157,0009,078,00092,745,728
12Jun 11, 2026 01:382,88335,174,69417,177,0009,059,00092,815,360