I have following json to be parsed and need to make different object
var object={"statusCode": 200, "headers": {}, "body": "{\"statusColor\": {\"abc1\": \"green\", \"abc2\": \"red\", \"bcd11\": \"red\", \"bcd2\": \"green\", \"cde1\": \"green\", \"cde2\": \"red\", \"efg1\": \"red\", \"efg2\": \"red\", \"efg3\": \"red\"}, \"time\":
{\"abc\": \"2020-02-03 11:41:40\", \"bcd\": \"2020-02-03 11:41:40\", \"cde\": \"2020-02-03 11:41:40\", \"efg\": \"2020-02-03 11:41:40\"}}"}
//Iam trying to get the seperate dict object for statusColor and time as below
var dict={}
dict=object
console.log("Status color is", dict.body['statusColor'])
#Out put is 'undefined'
Expected is : statusColor= 'get dict of all status color' similarly for time so what is the best approach to get the object dict from the multi json object?
stringrather than an object. this json object is not valid - check in jsonlint.combodyproperty:console.log("Status color is", JSON.parse(dict.body)['statusColor'])