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 13:07Victor MerckléVictor MerckléScore: 2,586Success
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 13:132,57232,548,88914,661,0008,749,00092,725,248stderr
2Aug 19, 2026 13:132,57531,811,72214,954,0008,482,00092,643,328stderr
3Aug 19, 2026 13:132,57631,892,22014,929,0008,513,00092,774,400stderr
4Aug 19, 2026 13:132,58331,848,89914,870,0008,641,00092,758,016stderr
5Aug 19, 2026 13:132,58632,530,80414,766,0008,772,00092,778,496stderr
6Aug 19, 2026 13:132,58631,854,70214,859,0008,682,00092,758,016stderr
7Aug 19, 2026 13:132,59232,711,27514,895,0008,698,00092,782,592stderr
8Aug 19, 2026 13:132,59532,057,14814,643,0008,977,00092,770,304stderr
9Aug 19, 2026 13:132,59932,730,09314,964,0008,689,00092,745,728stderr