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 08:20Victor MerckléVictor MerckléScore: 2,621Success
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 08:252,61632,148,15415,101,0008,706,00092,798,976stderr
2Aug 19, 2026 08:252,61932,272,47415,072,0008,764,00092,741,632stderr
3Aug 19, 2026 08:252,61932,849,13315,098,0008,739,00092,778,496stderr
4Aug 19, 2026 08:252,61932,215,97515,045,0008,795,00092,819,456stderr
5Aug 19, 2026 08:252,62132,143,89315,093,0008,766,00092,729,344stderr
6Aug 19, 2026 08:252,62532,908,27715,128,0008,763,00092,733,440stderr
7Aug 19, 2026 08:252,63432,959,18815,181,0008,792,00092,782,592stderr
8Aug 19, 2026 08:252,64333,212,46115,175,0008,880,00092,708,864stderr
9Aug 19, 2026 08:252,64633,134,92315,195,0008,887,00092,741,632stderr