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 18:47TudyMTudyMScore: 8,472Success
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 18:538,44193,099,05860,053,00016,767,00094,638,080
2May 3, 2026 18:538,44395,728,73760,056,00016,783,00094,638,080
3May 3, 2026 18:538,45694,103,95159,552,00017,401,00094,633,984
4May 3, 2026 18:538,46392,674,11759,441,00017,581,00094,646,272
5May 3, 2026 18:538,47292,692,40859,535,00017,565,00094,629,888
6May 3, 2026 18:538,47493,506,34359,488,00017,632,00094,629,888
7May 3, 2026 18:538,47492,628,35459,683,00017,435,00094,642,176
8May 3, 2026 18:538,49195,582,70359,794,00017,477,00094,642,176
9May 3, 2026 18:538,51493,165,17659,846,00017,634,00094,617,600