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

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 29, 2026 00:124,03556,315,71618,858,00017,866,00094,789,632
2Apr 29, 2026 00:124,04555,598,70018,902,00017,908,00094,789,632
3Apr 29, 2026 00:124,04553,791,17817,909,00018,904,00094,597,120
4Apr 29, 2026 00:124,05358,910,31417,945,00018,942,00094,789,632
5Apr 29, 2026 00:124,06458,927,51520,992,00015,993,00094,781,440
6Apr 29, 2026 00:124,06658,874,23420,005,00017,004,00094,797,824
7Apr 29, 2026 00:124,06655,115,85319,002,00018,002,00094,613,504
8Apr 29, 2026 00:124,07555,702,02219,046,00018,043,00094,601,216
9Apr 29, 2026 00:124,08659,729,61221,108,00016,082,00094,801,920