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 listAug 16, 2026 23:10Tomislav TunkovicTomislav TunkovicScore: 6,970Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 17, 2026 03:436,85172,299,29648,061,00014,284,00092,733,440
2Aug 17, 2026 03:436,85772,220,59948,119,00014,283,00092,704,768
3Aug 17, 2026 03:436,86372,275,91448,252,00014,202,00092,766,208
4Aug 17, 2026 03:436,96573,254,62249,199,00014,184,00092,766,208
5Aug 17, 2026 03:436,97073,329,56149,174,00014,259,00092,762,112
6Aug 17, 2026 03:437,01873,658,28749,733,00014,136,00092,766,208
7Aug 17, 2026 03:437,02474,094,01049,739,00014,180,00092,766,208
8Aug 17, 2026 03:437,03373,792,33249,760,00014,245,00092,708,864
9Aug 17, 2026 03:437,04373,888,01749,809,00014,291,00092,749,824