DE
_.get(obj, 'a1[1].b.c[3].res')Size: a a a
G
_.get(obj, 'a1[1].b.c[3].res')DE
js
function multiIndex(obj,is) { // obj,['1','2','3'] -> ((obj['1'])['2'])['3']
return is.length ? multiIndex(obj[is[0]],is.slice(1)) : obj
}
function pathIndex(obj,is) { // obj,'1.2.3' -> multiIndex(obj,['1','2','3'])
return multiIndex(obj,is.split('.'))
}
pathIndex('a.b.etc')
S
js
function multiIndex(obj,is) { // obj,['1','2','3'] -> ((obj['1'])['2'])['3']
return is.length ? multiIndex(obj[is[0]],is.slice(1)) : obj
}
function pathIndex(obj,is) { // obj,'1.2.3' -> multiIndex(obj,['1','2','3'])
return multiIndex(obj,is.split('.'))
}
pathIndex('a.b.etc')

G
js
function multiIndex(obj,is) { // obj,['1','2','3'] -> ((obj['1'])['2'])['3']
return is.length ? multiIndex(obj[is[0]],is.slice(1)) : obj
}
function pathIndex(obj,is) { // obj,'1.2.3' -> multiIndex(obj,['1','2','3'])
return multiIndex(obj,is.split('.'))
}
pathIndex('a.b.etc')
IS
_.get(obj, 'a1[1].b.c[3].res')DE
js
var dotize = dotize || {};
dotize.parse = function(jsonobj, prefix) {
var newobj = {};
function recurse(o, p) {
for (var f in o)
{
var pre = (p === undefined ? '' : p + ".");
if (o[f] && typeof o[f] === "object"){
newobj = recurse(o[f], pre + f);
} else {
newobj[pre + f] = o[f];
}
}
return newobj;
}
return recurse(jsonobj, prefix);
};
S
js
var dotize = dotize || {};
dotize.parse = function(jsonobj, prefix) {
var newobj = {};
function recurse(o, p) {
for (var f in o)
{
var pre = (p === undefined ? '' : p + ".");
if (o[f] && typeof o[f] === "object"){
newobj = recurse(o[f], pre + f);
} else {
newobj[pre + f] = o[f];
}
}
return newobj;
}
return recurse(jsonobj, prefix);
};

AN
'a1[1].b.c[3].res'.split(/[\[\].]+/).reduce((obj, key) => obj && obj[key], obj)⠀
'a1[1].b.c[3].res'.split(/[\[\].]+/).reduce((obj, key) => obj && obj[key], obj)G
'a1[1].b.c[3].res'.split(/[\[\].]+/).reduce((obj, key) => obj && obj[key], obj)DE
'a1[1].b.c[3].res'.split(/[\[\].]+/).reduce((obj, key) => obj && obj[key], obj)⠀
AN
AN
AN
IS
'a1[1].b.c[3].res'.split(/[\[\].]+/).reduce((obj, key) => obj && obj[key], obj)