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 15, 2026 23:43marko1597marko1597Score: 3,883Success
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:043,87543,619,22026,947,0008,322,00092,729,344stderr
2Aug 16, 2026 00:043,87743,608,71126,940,0008,341,00092,815,360stderr
3Aug 16, 2026 00:043,87843,651,13026,941,0008,357,00092,725,248stderr
4Aug 16, 2026 00:043,88243,676,82326,988,0008,339,00092,729,344stderr
5Aug 16, 2026 00:043,88343,695,68026,922,0008,422,00092,737,536stderr
6Aug 16, 2026 00:043,88744,480,41426,990,0008,383,00092,745,728stderr
7Aug 16, 2026 00:043,88844,471,97126,990,0008,398,00092,733,440stderr
8Aug 16, 2026 00:043,89643,778,08327,005,0008,456,00092,725,248stderr
9Aug 16, 2026 00:043,90044,527,70527,015,0008,476,00092,766,208stderr