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 listJul 7, 2026 04:04Victor MerckléVictor MerckléScore: 2,675Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 7, 2026 04:102,65132,150,59015,446,0008,686,00092,749,824stderr
2Jul 7, 2026 04:102,66232,659,87715,503,0008,725,00092,758,016stderr
3Jul 7, 2026 04:102,67132,703,28615,496,0008,816,00092,729,344stderr
4Jul 7, 2026 04:102,67132,413,74515,502,0008,809,00092,774,400stderr
5Jul 7, 2026 04:102,67532,555,85515,534,0008,809,00092,766,208stderr
6Jul 7, 2026 04:102,69332,889,13615,625,0008,887,00092,766,208stderr
7Jul 7, 2026 04:102,69832,867,83715,551,0009,003,00092,774,400stderr
8Jul 7, 2026 04:102,70133,044,38815,608,0008,972,00092,712,960stderr
9Jul 7, 2026 04:102,71233,016,36815,655,0009,025,00092,778,496stderr