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 listAug 14, 2026 18:23marko1597marko1597Score: 5,351Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 14, 2026 18:305,30358,247,93235,718,00012,541,00092,758,016stderr
2Aug 14, 2026 18:305,31658,397,29535,782,00012,597,00092,790,784stderr
3Aug 14, 2026 18:305,31758,412,92235,747,00012,643,00092,721,152stderr
4Aug 14, 2026 18:305,33958,589,14435,806,00012,781,00092,737,536stderr
5Aug 14, 2026 18:305,35158,669,85035,936,00012,763,00092,741,632stderr
6Aug 14, 2026 18:305,35559,851,59936,006,00012,727,00092,717,056stderr
7Aug 14, 2026 18:305,36459,143,82835,963,00012,855,00092,770,304stderr
8Aug 14, 2026 18:305,36958,822,02436,323,00012,537,00092,741,632stderr
9Aug 14, 2026 18:305,38058,879,61236,075,00012,888,00092,762,112stderr