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 listJun 11, 2026 18:07Victor MerckléVictor MerckléScore: 2,704Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 11, 2026 18:132,68533,444,19215,566,0008,872,00092,737,536
2Jun 11, 2026 18:132,68833,491,15615,730,0008,737,00092,782,592
3Jun 11, 2026 18:132,69233,605,62915,781,0008,720,00092,700,672
4Jun 11, 2026 18:132,70033,548,76015,833,0008,743,00092,819,456
5Jun 11, 2026 18:132,70433,627,69315,879,0008,735,00092,766,208
6Jun 11, 2026 18:132,71333,765,68915,884,0008,808,00092,737,536
7Jun 11, 2026 18:132,71733,771,35015,910,0008,822,00092,745,728
8Jun 11, 2026 18:132,71933,825,99515,921,0008,822,00092,712,960
9Jun 11, 2026 18:132,72733,811,57015,926,0008,896,00092,741,632