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 22, 2026 05:47olliecrowolliecrowScore: 5,534Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 22, 2026 05:525,48370,095,86733,931,00015,967,00094,752,768
2Apr 22, 2026 05:525,48556,770,38430,951,00018,970,00094,593,024
3Apr 22, 2026 05:525,49956,960,76831,028,00019,017,00094,593,024
4Apr 22, 2026 05:525,50957,187,10433,091,00017,047,00094,605,312
5Apr 22, 2026 05:525,53457,326,59732,231,00018,130,00094,601,216
6Apr 22, 2026 05:525,53857,416,36835,998,00014,399,00094,601,216
7Apr 22, 2026 05:525,54057,155,56233,276,00017,142,00094,601,216
8Apr 22, 2026 05:525,57856,791,14129,863,00020,904,00094,605,312
9Apr 22, 2026 05:525,58656,819,65531,899,00018,940,00094,760,960