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:45TudyMTudyMScore: 9,257Success
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:559,19798,876,95661,729,00021,965,00094,633,984
2May 3, 2026 15:559,21197,598,21961,886,00021,940,00094,629,888
3May 3, 2026 15:559,21997,820,96761,842,00022,051,00094,633,984
4May 3, 2026 15:559,22999,267,49861,903,00022,088,00094,633,984
5May 3, 2026 15:559,257100,701,36661,825,00022,422,00094,629,888
6May 3, 2026 15:559,258103,752,15061,905,00022,347,00094,629,888
7May 3, 2026 15:559,259101,163,54761,814,00022,446,00094,629,888
8May 3, 2026 15:559,26499,759,18461,718,00022,592,00094,633,984
9May 3, 2026 15:559,316103,040,74261,806,00022,978,00094,629,888