I trying to build a nested object, I'll try to make myself clear.
I have this json structure:
{
"origin.geo.country": "USA",
"origin.geo.state": "NY",
"origin.geo.zip": 4444,
"user.name": "Michael",
"user.surname": "Jordan"
}
And I need a function that outputs something like this:
{
origin: {
geo: {
country: "USA",
state: "NY",
zip: 4444
}
},
user: {
name: "Michael",
surname: "Jordan"
}
}
I know i have to use recursion to achieve this, but I'm not able to code it. Can you guys help me with this?
Thanks.