Skip to content

Top-level arrays to not round trip #66

@adamvoss

Description

@adamvoss

Given the following object as x:

[
    {
        "id": 2,
        "name": "An ice sculpture",
        "price": 12.50,
        "tags": ["cold", "ice"],
        "dimensions": {
            "length": 7.0,
            "width": 12.0,
            "height": 9.5
        },
        "warehouseLocation": {
            "latitude": -78.75,
            "longitude": 20.4
        }
    },
    {
        "id": 3,
        "name": "A blue mouse",
        "price": 25.50,
        "dimensions": {
            "length": 3.1,
            "width": 1.0,
            "height": 1.0
        },
        "warehouseLocation": {
            "latitude": 54.4,
            "longitude": -32.7
        }
    }
]

The following fails:

for (let y of ini.decode(ini.encode(x))) { console.log(y) }

despite the fact the following works:

for (let y of x) { console.log(y) }

The issue being that decoding results in an object where what was an array index is now a key, rather than create an array.

If this can be fixed, great. If it cannot because of backwards compatibility concerns, it would be nice if ini emitted a warning when encoding something that would not decode to an equivalent object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions