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 03:06Victor MerckléVictor MerckléError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 5, 2026 00:16Tomislav Tunkovic10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 5, 2026 01:44021,839,9668,393,0004,837,00041,844,736invalid character 's' looking for beginning of value
2Sep 5, 2026 01:44021,677,0358,514,0004,789,00041,840,640invalid character 's' looking for beginning of value
3Sep 5, 2026 01:44021,584,4938,468,0004,652,00041,857,024invalid character 's' looking for beginning of value
4Jun 11, 2026 03:132,83635,295,07316,986,0008,830,00092,733,440
5Jun 11, 2026 03:132,83934,883,90117,011,0008,824,00092,745,728
6Jun 11, 2026 03:132,84035,184,36016,982,0008,865,00092,762,112
7Jun 11, 2026 03:132,84236,044,70117,004,0008,862,00092,786,688
8Jun 11, 2026 03:132,86236,231,70217,109,0008,943,00092,770,304
9Jun 11, 2026 03:132,86835,415,50116,978,0009,121,00092,753,920
10Jun 11, 2026 03:132,87033,708,94016,559,0009,562,00092,798,976
11Jun 11, 2026 03:132,87636,704,90717,164,0009,010,00092,749,824
12Jun 11, 2026 03:132,87936,244,60717,208,0008,999,00092,749,824