Javascript nested object -


this question has answer here:

considering following javascript object below:

object

{     _id: "553ea677da00122e5413d8c2",     {         "labyname": "mq",         "data": [             [                 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],                 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],                 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],                 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],                 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],                 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],                 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],                 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],                 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],                 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]             ],             [                 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],                 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],                 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],                 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],                 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],                 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],                 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],                 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],                 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],                 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]             ], null, null, null, null, "mq"]     }: "" } 

to access id in object can that:

var=object[0]["_id"]

can tell me how access "labyname" , "data?

something wrong object. looks have object 2 properties: _id , json string has empty string value. if have (may coding gods have mercy on algorithms) need second key filtering out _id , parsing other key object. like:

var json = object.keys(your_crazy_object).filter(function (key) { return key !== '_id'; })[0]; var obj = json.parse(json); console.log(obj.labyname); // "mq" console.log(obj.data); // [[[1,1,1,...,1,1,1]], [[1,1,1,...,1,1,1]], null, null, null, null, "mq"]