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 00:06marko1597marko1597Score: 3,514Success
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 00:403,49540,205,84023,515,0008,290,00092,741,632stderr
2Aug 16, 2026 00:403,50640,258,90523,567,0008,340,00092,733,440stderr
3Aug 16, 2026 00:403,50641,068,56023,577,0008,336,00092,680,192stderr
4Aug 16, 2026 00:403,50840,378,33923,575,0008,353,00092,753,920stderr
5Aug 16, 2026 00:403,51441,077,17523,636,0008,345,00092,721,152stderr
6Aug 16, 2026 00:403,51440,305,64123,575,0008,407,00092,737,536stderr
7Aug 16, 2026 00:403,52441,088,60723,652,0008,417,00092,745,728stderr
8Aug 16, 2026 00:403,52641,366,46223,654,0008,435,00092,733,440stderr
9Aug 16, 2026 00:403,53240,434,87523,745,0008,401,00092,762,112stderr