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 CabergsScore: 4,210Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 28, 2026 05:134,19357,548,83620,084,00018,075,00094,793,728
2Apr 28, 2026 05:134,19955,687,34821,121,00017,098,00094,789,632
3Apr 28, 2026 05:134,20260,997,48323,148,00015,096,00094,793,728
4Apr 28, 2026 05:134,20757,310,23822,166,00016,120,00094,806,016
5Apr 28, 2026 05:134,21056,947,94519,160,00019,160,00094,801,920
6Apr 28, 2026 05:134,21753,779,74620,198,00018,178,00094,789,632
7Apr 28, 2026 05:134,21861,101,41922,227,00016,165,00094,801,920
8Apr 28, 2026 05:134,23854,108,07620,302,00018,271,00094,797,824
9Apr 28, 2026 05:134,24156,490,21819,793,00018,804,00094,797,824