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 30, 2026 18:11Charles CabergsCharles CabergsScore: 4,067Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 30, 2026 18:134,05058,743,73317,930,00018,926,00094,789,632
2Apr 30, 2026 18:134,05255,180,06417,943,00018,939,00094,801,920
3Apr 30, 2026 18:134,06255,156,33419,981,00016,984,00094,793,728
4Apr 30, 2026 18:134,06652,834,34918,003,00019,004,00094,797,824
5Apr 30, 2026 18:134,06755,616,01516,007,00021,010,00094,797,824
6Apr 30, 2026 18:134,07656,504,74417,042,00020,050,00094,801,920
7Apr 30, 2026 18:134,08055,027,84018,062,00019,066,00094,801,920
8Apr 30, 2026 18:134,08456,315,61316,075,00021,098,00094,797,824
9Apr 30, 2026 18:134,08561,148,26815,073,00022,107,00094,789,632