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 28, 2026 05:11Charles CabergsCharles CabergsError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Jul 6, 2026 09:02Victor Mercklé10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 6, 2026 09:03011,436,13602,010,0002,121,728invalid character '<' after object key:value pair
2Jul 6, 2026 09:03011,394,02201,994,0002,121,728invalid character '<' after object key:value pair
3Jul 6, 2026 09:03011,370,87602,001,0002,121,728invalid character '<' after object key:value pair
4Apr 28, 2026 05:134,19357,548,83620,084,00018,075,00094,793,728
5Apr 28, 2026 05:134,19955,687,34821,121,00017,098,00094,789,632
6Apr 28, 2026 05:134,20260,997,48323,148,00015,096,00094,793,728
7Apr 28, 2026 05:134,20757,310,23822,166,00016,120,00094,806,016
8Apr 28, 2026 05:134,21056,947,94519,160,00019,160,00094,801,920
9Apr 28, 2026 05:134,21753,779,74620,198,00018,178,00094,789,632
10Apr 28, 2026 05:134,21861,101,41922,227,00016,165,00094,801,920
11Apr 28, 2026 05:134,23854,108,07620,302,00018,271,00094,797,824
12Apr 28, 2026 05:134,24156,490,21819,793,00018,804,00094,797,824