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 20, 2026 05:25olliecrowolliecrowScore: 4,382Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 20, 2026 05:254,35266,390,74920,791,00018,811,00094,547,968
2Mar 20, 2026 05:254,35763,328,66722,799,00016,851,00094,679,040
3Mar 20, 2026 05:254,36664,858,44523,839,00015,893,00094,547,968
4Mar 20, 2026 05:254,37367,948,56822,883,00016,913,00094,547,968
5Mar 20, 2026 05:254,38260,731,52722,928,00016,947,00094,539,776
6Mar 20, 2026 05:254,39660,310,83525,002,00015,001,00094,793,728
7Mar 20, 2026 05:254,40265,138,91923,032,00017,024,00094,687,232
8Mar 20, 2026 05:254,40864,214,62422,060,00018,049,00094,674,944
9Mar 20, 2026 05:254,42165,476,90821,121,00019,110,00094,666,752