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 3, 2026 15:22TudyMTudyMScore: 12,826Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 3, 2026 15:3312,781131,855,49798,510,00017,803,00094,642,176
2May 3, 2026 15:3312,809132,907,63199,198,00017,366,00094,633,984
3May 3, 2026 15:3312,814130,876,26999,247,00017,366,00094,638,080
4May 3, 2026 15:3312,817133,673,12899,206,00017,432,00094,629,888
5May 3, 2026 15:3312,826130,809,95299,245,00017,476,00094,638,080
6May 3, 2026 15:3312,828131,897,98799,313,00017,422,00094,646,272
7May 3, 2026 15:3312,831135,958,36599,320,00017,449,00094,629,888
8May 3, 2026 15:3312,848135,533,54499,103,00017,814,00094,625,792
9May 3, 2026 15:3312,870133,835,24199,090,00018,034,00094,629,888