[Solved] Jquery object assign to variable return undefined [duplicate]


property_object_parse is a real JavaScript object, so you can just use the member access syntax to access the value you are interested in directly:

console.log(property_object_parse.p1.TextElement[0].size);

Note that you cannot use a dynamic property path string like 'p1.TextElement[0].size', you would have to compile that in a way. For example, you could instead have an array of properties you are trying to access:

var selected_element = ['p1', 'TextElement', '0', 'size'];
var obj = property_object_parse;
for (var i = 0; i < selected_element.length; i++) {
    obj = obj[selected_element[i]];
}
console.log(obj);

That has the same result as accessing it all directly as above with property_object_parse.p1.TextElement[0].size.

1

solved Jquery object assign to variable return undefined [duplicate]