hughsk / flat

:steam_locomotive: Flatten/unflatten nested Javascript objects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Deep Nested Objects

9thstudio opened this issue · comments

Hi
I have deep nested objects but looks unflatten just deep down to 3 levels. Let me know if I am missing something

const mainObj =  {
sub1.sub2': 'abc',
sub1.sub2.sub3.sub4': 'xyz'
}
test = unflatten(mainObj);
console.log(test);

results in

mainObj: {
sub1: {
sub2: 'abc',
sub3: [Object]
}

Can't get value down to sub4 or below. It always shows [Object]. Is there a limit?

I have the same issue. did you manage to solve it by any chance?

The problem is with your input. There are duplicate entries for sub1.sub2, one of them being the value 'abc' and the other is sub1.sub2.sub3. Since sub1.sub2 is already a string value it cannot also be an object.