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 listNov 3, 2026 03:59Andrew EpsteinAndrew EpsteinScore: 2,604Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 3, 2026 04:112,58434,407,02814,759,0008,763,00092,835,840
2Nov 3, 2026 04:112,58534,432,20115,018,0008,511,00092,786,688
3Nov 3, 2026 04:112,58634,303,68714,795,0008,741,00092,753,920
4Nov 3, 2026 04:112,58934,402,58814,756,0008,804,00092,749,824
5Nov 3, 2026 04:112,60434,495,59614,855,0008,845,00092,766,208
6Nov 3, 2026 04:112,60934,563,21615,229,0008,517,00092,745,728
7Nov 3, 2026 04:112,61435,215,73514,989,0008,800,00092,729,344
8Nov 3, 2026 04:112,62834,786,18614,991,0008,931,00092,753,920
9Nov 3, 2026 04:112,63535,356,06615,053,0008,927,00092,737,536