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 06:29Victor MerckléVictor MerckléScore: 2,685Success
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 06:352,66232,688,63415,510,0008,721,00092,745,728stderr
2Aug 19, 2026 06:352,66733,410,30015,532,0008,743,00092,774,400stderr
3Aug 19, 2026 06:352,67332,902,30015,575,0008,750,00092,712,960stderr
4Aug 19, 2026 06:352,67833,337,30915,596,0008,781,00092,758,016stderr
5Aug 19, 2026 06:352,68533,379,20415,649,0008,786,00092,790,784stderr
6Aug 19, 2026 06:352,68833,442,01415,644,0008,820,00092,729,344stderr
7Aug 19, 2026 06:352,69233,552,94915,635,0008,869,00092,737,536stderr
8Aug 19, 2026 06:352,69733,673,70215,669,0008,875,00092,672,000stderr
9Aug 19, 2026 06:352,70033,561,09315,665,0008,908,00092,729,344stderr