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 listSep 15, 2026 14:36Victor MerckléVictor MerckléScore: 2,843Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 15, 2026 14:482,83235,133,65017,182,0008,597,00092,753,920stderr
2Sep 15, 2026 14:482,84034,733,57517,147,0008,700,00092,749,824stderr
3Sep 15, 2026 14:482,84034,848,41617,117,0008,734,00092,762,112stderr
4Sep 15, 2026 14:482,84135,254,84617,148,0008,711,00092,696,576stderr
5Sep 15, 2026 14:482,84334,523,68017,119,0008,761,00092,692,480stderr
6Sep 15, 2026 14:482,84334,635,10917,295,0008,584,00092,741,632stderr
7Sep 15, 2026 14:482,85334,945,21017,140,0008,824,00092,770,304stderr
8Sep 15, 2026 14:482,85536,725,15017,271,0008,717,00092,712,960stderr
9Sep 15, 2026 14:482,85834,753,67917,324,0008,689,00092,749,824stderr