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 listMay 18, 2026 05:42M-RochatM-RochatScore: 6,974Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 18, 2026 05:536,96772,583,78255,045,0008,363,00092,721,152
2May 18, 2026 05:536,97174,492,81355,126,0008,315,00092,753,920
3May 18, 2026 05:536,97272,590,03755,096,0008,356,00092,794,880
4May 18, 2026 05:536,97272,547,10055,054,0008,397,00092,790,784
5May 18, 2026 05:536,97473,625,53455,002,0008,464,00092,733,440
6May 18, 2026 05:536,97974,405,58055,064,0008,446,00092,778,496
7May 18, 2026 05:536,98072,563,93955,084,0008,434,00092,712,960
8May 18, 2026 05:536,98173,934,62355,094,0008,440,00092,708,864
9May 18, 2026 05:536,99272,981,35855,159,0008,476,00092,774,400