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 16, 2026 13:14marko1597marko1597Score: 37,443Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 16, 2026 13:2937,359348,346,133331,786,0008,183,00092,712,960stderr
2Aug 16, 2026 13:2937,371348,517,848331,915,0008,165,00092,762,112stderr
3Aug 16, 2026 13:2937,394348,720,096332,116,0008,173,00092,745,728stderr
4Aug 16, 2026 13:2937,402348,757,663332,172,0008,188,00092,692,480stderr
5Aug 16, 2026 13:2937,443349,100,736332,487,0008,248,00092,766,208stderr
6Aug 16, 2026 13:2937,521349,857,184333,277,0008,167,00092,766,208stderr
7Aug 16, 2026 13:2937,579350,368,821333,697,0008,277,00092,741,632stderr
8Aug 16, 2026 13:2937,612350,831,295333,995,0008,283,00092,737,536stderr
9Aug 16, 2026 13:2937,727351,707,607334,992,0008,327,00092,770,304stderr