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 14, 2026 16:23Tomislav TunkovicTomislav TunkovicScore: 5,974Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 14, 2026 16:305,95562,398,65023,079,00031,112,00094,400,512stderr
2Aug 14, 2026 16:305,96062,403,85923,033,00031,205,00094,400,512stderr
3Aug 14, 2026 16:305,97062,741,65823,071,00031,259,00094,400,512stderr
4Aug 14, 2026 16:305,97262,627,74723,037,00031,313,00094,400,512stderr
5Aug 14, 2026 16:305,97462,575,07223,144,00031,220,00094,400,512stderr
6Aug 14, 2026 16:305,98162,651,08323,106,00031,330,00094,400,512stderr
7Aug 14, 2026 16:305,99262,707,09623,107,00031,428,00094,400,512stderr
8Aug 14, 2026 16:305,99362,981,82423,209,00031,334,00094,400,512stderr
9Aug 14, 2026 16:306,01263,019,20323,190,00031,526,00094,400,512stderr