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 4, 2026 19:51Victor MerckléVictor MerckléScore: 3,140Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 4, 2026 19:563,12641,020,94419,789,0008,661,00093,085,696
2May 4, 2026 19:563,13441,865,76619,811,0008,710,00093,085,696
3May 4, 2026 19:563,13942,526,68819,842,0008,727,00093,077,504
4May 4, 2026 19:563,13941,958,08220,000,0008,565,00093,147,136
5May 4, 2026 19:563,14041,987,64319,806,0008,770,00093,085,696
6May 4, 2026 19:563,14445,793,77220,004,0008,607,00093,155,328
7May 4, 2026 19:563,14442,652,80419,870,0008,746,00093,073,408
8May 4, 2026 19:563,15643,737,40920,062,0008,663,00093,134,848
9May 4, 2026 19:563,16042,954,43720,077,0008,685,00093,147,136