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 5, 2026 04:38Andrew EpsteinAndrew EpsteinScore: 2,363Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 5, 2026 04:462,34330,556,39412,874,0008,449,00092,753,920
2Nov 5, 2026 04:462,35930,740,70612,929,0008,542,00092,737,536
3Nov 5, 2026 04:462,36030,820,94212,951,0008,530,00092,770,304
4Nov 5, 2026 04:462,36130,739,05713,029,0008,463,00092,774,400
5Nov 5, 2026 04:462,36330,843,27813,019,0008,493,00092,798,976
6Nov 5, 2026 04:462,36430,792,01613,063,0008,456,00092,729,344
7Nov 5, 2026 04:462,37230,905,41913,135,0008,457,00092,741,632
8Nov 5, 2026 04:462,37230,955,15613,010,0008,576,00092,790,784
9Nov 5, 2026 04:462,38030,986,84513,227,0008,439,00092,721,152