Object turns into an array after unflattening
- Dominant language
- JavaScript
- Stars
- 1.8k
- Forks
- 197
- PR merge metrics
- No merged PRs in 30d
Description
``` javascript
var flat = require("flat");
var data = {
"object": {"0": "a", "1": "b"}
};
console.log(flat.unflatten(flat.flatten(data)));
```
Outputs
``` javascript
{ object: [ 'a', 'b' ] }
```
Not sure how often people would use integers as object keys, but is a valid case nonetheless.
I realize that yes, you can pass `{object:true}` to unflatten, and it will not automatically assume it's an array, but then you get the opposite behavior. i.e. "Arrays turn into objects".
A more generic solution would be to use square brackets in the flattened format, where:
`object[0]`, and `object.0` imply different data structures.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.