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 19, 2026 09:47Victor MerckléVictor MerckléScore: 2,610Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 19, 2026 09:532,59033,456,52514,843,0008,730,00092,733,440stderr
2Aug 19, 2026 09:532,59232,753,59714,841,0008,753,00092,782,592stderr
3Aug 19, 2026 09:532,59631,986,60614,872,0008,754,00092,733,440stderr
4Aug 19, 2026 09:532,60532,218,17614,855,0008,851,00092,774,400stderr
5Aug 19, 2026 09:532,61032,686,73514,960,0008,794,00092,741,632stderr
6Aug 19, 2026 09:532,61132,071,97714,978,0008,791,00092,753,920stderr
7Aug 19, 2026 09:532,61232,177,64015,192,0008,580,00092,741,632stderr
8Aug 19, 2026 09:532,61532,118,68814,923,0008,880,00092,737,536stderr
9Aug 19, 2026 09:532,62032,740,82014,964,0008,883,00092,729,344stderr