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 13:44Victor MerckléVictor MerckléScore: 2,468Success
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 13:502,45431,529,73013,770,0008,568,00092,741,632stderr
2Aug 19, 2026 13:502,45930,809,62713,812,0008,569,00092,749,824stderr
3Aug 19, 2026 13:502,45931,372,32913,759,0008,624,00092,762,112stderr
4Aug 19, 2026 13:502,46131,466,79913,866,0008,538,00092,733,440stderr
5Aug 19, 2026 13:502,46831,521,15313,932,0008,533,00092,753,920stderr
6Aug 19, 2026 13:502,46930,901,85613,909,0008,561,00092,778,496stderr
7Aug 19, 2026 13:502,47630,979,26513,930,0008,603,00092,717,056stderr
8Aug 19, 2026 13:502,48531,595,65913,889,0008,728,00092,778,496stderr
9Aug 19, 2026 13:502,50031,796,09414,014,0008,739,00092,725,248stderr