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 03:57olliecrowolliecrowScore: 4,422Success
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 03:574,39064,362,93221,974,00017,978,00094,547,968
2Mar 20, 2026 03:574,39567,257,54022,994,00016,996,00094,674,944
3Mar 20, 2026 03:574,39665,292,18624,005,00016,003,00094,547,968
4Mar 20, 2026 03:574,42069,781,95224,133,00016,088,00094,547,968
5Mar 20, 2026 03:574,42262,318,49724,142,00016,095,00094,674,944
6Mar 20, 2026 03:574,42862,551,62022,162,00018,133,00094,547,968
7Mar 20, 2026 03:574,43870,230,22223,222,00017,164,00094,674,944
8Mar 20, 2026 03:574,43863,226,77722,213,00018,174,00094,793,728
9Mar 20, 2026 03:574,44063,593,96723,233,00017,172,00094,674,944