hughsk / hughsk/flat

What option to make difference between object & array

Open
#115 1 comment 5 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.8k
Forks
197
PR merge metrics
No merged PRs in 30d

Description

I make a sample to test the

``` javascript
const flat = require("flat");

const data = {
object: {
'0': 2,
},
array: [2],
};

console.log('Before', data);

const result = flat.flatten(data);

console.log("Flatten", result);

const atad = flat.unflatten(result);

console.log('After', atad);
```

And the result

``` console
Before { object: { '0': 2 }, array: [ 2 ] }
Flatten { 'object.0': 2, 'array.0': 2 }
After { object: [ 2 ], array: [ 2 ] }
````

The object is flatted and unflatten is not the same as the original. It should be the same. I think the problem from

```
Flatten { 'object.0': 2, 'array.0': 2 }
```

It should be

```
Flatten { 'object.0': 2, 'array[0]': 2 }
```

This behavior should similar to `qs` library. So please provide the option to do that.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.