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 07:13Victor MerckléVictor MerckléScore: 2,677Success
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 07:182,64432,487,40115,421,0008,645,00092,782,592stderr
2Aug 19, 2026 07:182,65833,183,88015,489,0008,703,00092,741,632stderr
3Aug 19, 2026 07:182,66432,669,56015,469,0008,782,00092,741,632stderr
4Aug 19, 2026 07:182,67332,709,84515,550,0008,782,00092,704,768stderr
5Aug 19, 2026 07:182,67732,707,70215,579,0008,784,00092,741,632stderr
6Aug 19, 2026 07:182,67934,176,01315,584,0008,798,00092,737,536stderr
7Aug 19, 2026 07:182,68232,776,06015,587,0008,828,00092,753,920stderr
8Aug 19, 2026 07:182,68633,427,91015,630,0008,821,00092,717,056stderr
9Aug 19, 2026 07:182,69933,527,79415,669,0008,895,00092,758,016stderr