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 07:54Tomislav TunkovicTomislav TunkovicScore: 2,847Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 15, 2026 08:012,83434,230,52317,154,0008,638,00092,729,344
2Aug 15, 2026 08:012,83534,204,51717,180,0008,619,00092,786,688
3Aug 15, 2026 08:012,83533,983,93417,177,0008,628,00092,762,112
4Aug 15, 2026 08:012,83834,250,51717,193,0008,641,00092,676,096
5Aug 15, 2026 08:012,84734,140,46517,191,0008,725,00092,737,536
6Aug 15, 2026 08:012,84734,087,90017,235,0008,676,00092,766,208
7Aug 15, 2026 08:012,85134,118,42917,187,0008,759,00092,770,304
8Aug 15, 2026 08:012,85434,254,18517,219,0008,754,00092,725,248
9Aug 15, 2026 08:012,85534,435,90117,242,0008,741,00092,684,288