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 30, 2026 17:39Dominique GarmierDominique GarmierScore: 8,681Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 30, 2026 17:538,635109,291,41031,830,00046,751,00094,765,056
2Mar 30, 2026 17:398,636105,728,12229,843,00048,744,00094,777,344
3Mar 30, 2026 21:258,659103,068,67428,926,00049,873,00094,674,944
4Mar 30, 2026 21:258,673106,566,46537,962,00040,959,00094,732,288
5Mar 30, 2026 21:258,681102,946,62930,000,00049,000,00094,707,712
6Mar 30, 2026 17:538,682104,706,31731,001,00048,001,00094,687,232
7Mar 30, 2026 17:398,776104,724,54731,943,00047,915,00094,687,232
8Mar 30, 2026 17:398,816106,841,07925,070,00055,155,00094,740,480
9Mar 30, 2026 17:538,902108,330,88127,001,00054,003,00094,736,384