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 16:55Victor MerckléVictor MerckléScore: 2,452Success
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 17:042,44131,263,44613,679,0008,543,00092,733,440stderr
2Aug 19, 2026 17:042,44330,519,36513,726,0008,506,00092,712,960stderr
3Aug 19, 2026 17:042,44831,282,96513,737,0008,544,00092,737,536stderr
4Aug 19, 2026 17:042,44931,229,03813,750,0008,536,00092,753,920stderr
5Aug 19, 2026 17:042,45231,281,66713,735,0008,586,00092,770,304stderr
6Aug 19, 2026 17:042,45330,659,99813,766,0008,561,00092,823,552stderr
7Aug 19, 2026 17:042,46631,360,56213,773,0008,674,00092,688,384stderr
8Aug 19, 2026 17:042,47030,805,17413,800,0008,686,00092,790,784stderr
9Aug 19, 2026 17:042,47331,479,25513,835,0008,675,00092,778,496stderr