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 14:41TudyMTudyMScore: 11,325Success
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 14:5011,310121,099,27085,573,00017,354,00094,633,984
2May 3, 2026 14:5011,313122,737,30485,683,00017,274,00094,650,368
3May 3, 2026 14:5011,319120,204,21685,588,00017,415,00094,642,176
4May 3, 2026 14:5011,323119,311,66585,587,00017,457,00094,621,696
5May 3, 2026 14:5011,325119,333,35685,637,00017,425,00094,646,272
6May 3, 2026 14:5011,360118,814,06185,856,00017,527,00094,621,696
7May 3, 2026 14:5011,380119,418,90286,247,00017,313,00094,617,600
8May 3, 2026 14:5011,412120,319,14086,112,00017,738,00094,629,888
9May 3, 2026 14:5011,416121,349,22286,497,00017,397,00094,629,888