text = {
content:{
joldy:{
age: 20
}
}
}
key = 'content.joldy.age';
var keys = key.split(".");
console.log(keys)
for (var j = 0; j < keys.length; j++) {
if (keys[j].indexOf("[") > 0) {
var kk = keys[j].substring(0, keys[j].indexOf("["));
var vv = keys[j].substring(keys[j].indexOf("[") + 1, keys[j].indexOf("]"));
if (text[kk] && text[kk].length >= vv) {
text = text[kk][vv]
} else {
text = null
}
} else {
if (text != null && text[keys[j]]) {
text = text[keys[j]]
} else {
text = ""
}
}
}
console.log(text)