Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Top-level arrays to not round trip #66

Open
adamvoss opened this issue Jul 10, 2017 · 0 comments
Open

Top-level arrays to not round trip #66

adamvoss opened this issue Jul 10, 2017 · 0 comments

Comments

@adamvoss
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@adamvoss and others