How to turn a JSON To a properties array in JS, no matter what's the JSON's depth ?
JSON
{
"foo": {
"bar": {
"baz": "UP"
}
}
}
key/value properties
{
"foo.bar.baz": "UP"
}
One-level solution
My current code only treats one level, instead of n:
var user = {name: 'Corbin', age: 20, location: 'USA'},
key;
for (key in user) {
if (user.hasOwnProperty(key)) {
console.log(key + " = " + user[key]);
}
}
Thank you :D