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 06:57M-RochatM-RochatError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Jul 6, 2026 11:07Victor Mercklé10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 6, 2026 11:09057,295,35639,395,0008,345,00092,893,184invalid character '<' after object key:value pair
2Jul 6, 2026 11:09057,312,37139,371,0008,480,00092,893,184invalid character '<' after object key:value pair
3Jul 6, 2026 11:09057,175,57639,471,0008,290,00092,893,184invalid character '<' after object key:value pair
4May 18, 2026 07:105,37458,176,65240,657,0008,248,00092,774,400
5May 18, 2026 07:105,39258,203,65140,770,0008,301,00092,725,248
6May 18, 2026 07:105,39658,244,88840,797,0008,310,00092,815,360
7May 18, 2026 07:105,40058,255,76340,830,0008,311,00092,749,824
8May 18, 2026 07:105,40158,324,39640,782,0008,376,00092,721,152
9May 18, 2026 07:105,40161,178,39240,828,0008,329,00092,725,248
10May 18, 2026 07:105,40360,334,80140,760,0008,409,00092,770,304
11May 18, 2026 07:105,40559,367,06340,807,0008,386,00092,753,920
12May 18, 2026 07:105,41658,568,53341,010,0008,282,00092,778,496