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 listMay 18, 2026 07:55M-RochatM-RochatError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Jul 6, 2026 10:07Victor Mercklé10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 6, 2026 10:08052,876,09534,997,0008,371,00092,893,184invalid character '<' after object key:value pair
2Jul 6, 2026 10:08052,792,03735,027,0008,405,00092,893,184invalid character '<' after object key:value pair
3Jul 6, 2026 10:08052,878,15135,035,0008,483,00092,893,184invalid character '<' after object key:value pair
4May 18, 2026 08:064,96355,032,24536,841,0008,324,00092,815,360
5May 18, 2026 08:064,96554,578,65236,835,0008,347,00092,700,672
6May 18, 2026 08:064,96754,236,79136,841,0008,365,00092,749,824
7May 18, 2026 08:064,97154,426,48136,890,0008,349,00092,758,016
8May 18, 2026 08:064,97354,391,41636,894,0008,368,00092,741,632
9May 18, 2026 08:064,97756,228,22136,796,0008,501,00092,737,536
10May 18, 2026 08:064,98457,207,57636,942,0008,418,00092,733,440
11May 18, 2026 08:064,98555,033,91436,938,0008,428,00092,667,904
12May 18, 2026 08:064,99554,626,37037,036,0008,425,00092,712,960