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 3, 2026 16:55Victor MerckléVictor MerckléScore: 2,799Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 3, 2026 17:042,76934,802,06216,700,0008,501,00092,737,536stderr
2Jul 3, 2026 17:042,78034,796,07316,678,0008,621,00092,753,920stderr
3Jul 3, 2026 17:042,78635,467,22216,791,0008,564,00092,749,824stderr
4Jul 3, 2026 17:042,79434,977,63416,800,0008,634,00092,774,400stderr
5Jul 3, 2026 17:042,79935,291,78316,759,0008,718,00092,700,672stderr
6Jul 3, 2026 17:042,80135,484,75116,768,0008,728,00092,803,072stderr
7Jul 3, 2026 17:042,80335,445,75416,760,0008,754,00092,778,496stderr
8Jul 3, 2026 17:042,82435,275,05116,886,0008,817,00092,766,208stderr
9Jul 3, 2026 17:042,82535,653,96216,837,0008,878,00092,721,152stderr