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 listApr 29, 2026 00:10Charles CabergsCharles CabergsError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Jul 6, 2026 08:15Victor Mercklé10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 6, 2026 08:17012,020,02502,169,0002,121,728invalid character '<' after object key:value pair
2Jul 6, 2026 08:17012,016,90502,164,0002,121,728invalid character '<' after object key:value pair
3Jul 6, 2026 08:17020,322,48602,121,0002,121,728invalid character '<' after object key:value pair
4Apr 29, 2026 00:124,03556,315,71618,858,00017,866,00094,789,632
5Apr 29, 2026 00:124,04555,598,70018,902,00017,908,00094,789,632
6Apr 29, 2026 00:124,04553,791,17817,909,00018,904,00094,597,120
7Apr 29, 2026 00:124,05358,910,31417,945,00018,942,00094,789,632
8Apr 29, 2026 00:124,06458,927,51520,992,00015,993,00094,781,440
9Apr 29, 2026 00:124,06658,874,23420,005,00017,004,00094,797,824
10Apr 29, 2026 00:124,06655,115,85319,002,00018,002,00094,613,504
11Apr 29, 2026 00:124,07555,702,02219,046,00018,043,00094,601,216
12Apr 29, 2026 00:124,08659,729,61221,108,00016,082,00094,801,920