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 07:54marko1597marko1597Score: 3,279Success
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 08:203,24937,875,70321,282,0008,284,00092,774,400stderr
2Aug 16, 2026 08:203,25538,055,93121,327,0008,302,00092,766,208stderr
3Aug 16, 2026 08:203,26338,043,40821,361,0008,335,00092,725,248stderr
4Aug 16, 2026 08:203,26738,139,68621,412,0008,320,00092,704,768stderr
5Aug 16, 2026 08:203,27938,188,50521,472,0008,368,00092,778,496stderr
6Aug 16, 2026 08:203,28038,252,71821,364,0008,491,00092,745,728stderr
7Aug 16, 2026 08:203,29038,472,52321,505,0008,439,00092,778,496stderr
8Aug 16, 2026 08:203,30638,521,45421,656,0008,436,00092,803,072stderr
9Aug 16, 2026 08:203,32838,704,70121,859,0008,428,00092,745,728stderr