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 08:41Victor MerckléVictor MerckléScore: 2,772Success
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 08:462,75633,508,29316,645,0008,441,00092,766,208stderr
2Aug 19, 2026 08:462,76134,184,94516,682,0008,450,00092,741,632stderr
3Aug 19, 2026 08:462,76734,307,52516,619,0008,566,00092,692,480stderr
4Aug 19, 2026 08:462,77133,540,46016,765,0008,460,00092,712,960stderr
5Aug 19, 2026 08:462,77233,567,28016,683,0008,549,00092,753,920stderr
6Aug 19, 2026 08:462,77533,836,06016,481,0008,780,00092,766,208stderr
7Aug 19, 2026 08:462,79633,773,85216,768,0008,682,00092,782,592stderr
8Aug 19, 2026 08:462,79634,536,14316,764,0008,685,00092,729,344stderr
9Aug 19, 2026 08:462,79733,866,39416,776,0008,680,00092,729,344stderr