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 10, 2026 04:16olliecrowolliecrowScore: 8,020Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 10, 2026 04:168,01394,688,94655,938,00016,981,00094,547,968
2Mar 10, 2026 04:168,01495,742,79755,942,00016,982,00094,662,656
3Mar 10, 2026 04:168,01697,178,97553,960,00018,986,00094,564,352
4Mar 10, 2026 04:168,02096,539,64356,987,00015,996,00094,564,352
5Mar 10, 2026 04:168,02094,252,23353,990,00018,996,00094,547,968
6Mar 10, 2026 04:168,02794,577,64957,033,00016,009,00094,547,968
7Mar 10, 2026 04:168,03397,413,43555,076,00018,025,00094,543,872
8Mar 10, 2026 04:168,05099,817,00957,196,00016,055,00094,552,064
9Mar 10, 2026 04:168,08597,351,45154,681,00018,889,00094,564,352