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 listMar 4, 2026 00:00olliecrowolliecrowScore: 12,316Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 4, 2026 00:0012,285134,724,88593,828,00017,967,00094,552,064
2Mar 4, 2026 00:0012,294139,243,39195,892,00015,982,00094,552,064
3Mar 4, 2026 00:0012,307142,156,37994,994,00016,998,00094,547,968
4Mar 4, 2026 00:0012,313142,868,22895,044,00017,007,00094,781,440
5Mar 4, 2026 00:0012,316137,170,26796,069,00016,011,00094,547,968
6Mar 4, 2026 00:0012,326138,706,41892,141,00020,030,00094,568,448
7Mar 4, 2026 00:0012,329134,947,10597,169,00015,026,00094,572,544
8Mar 4, 2026 00:0012,339137,173,31096,242,00016,040,00094,568,448
9Mar 4, 2026 00:0012,366138,594,59095,452,00017,080,00094,556,160