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 listMay 5, 2026 06:16Victor MerckléVictor MerckléScore: 3,142Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 5, 2026 06:263,11243,863,89619,381,0008,942,00093,081,600
2May 5, 2026 06:263,13142,346,29019,443,0009,051,00093,114,368
3May 5, 2026 06:263,13344,803,36619,934,0008,579,00093,151,232
4May 5, 2026 06:263,13444,173,89119,921,0008,599,00093,151,232
5May 5, 2026 06:263,14242,572,21919,792,0008,808,00093,106,176
6May 5, 2026 06:263,14944,283,53319,987,0008,672,00093,122,560
7May 5, 2026 06:263,15143,694,73319,944,0008,733,00093,118,464
8May 5, 2026 06:263,15244,485,37920,070,0008,621,00093,085,696
9May 5, 2026 06:263,15241,375,37620,031,0008,658,00093,102,080