带转义符的json解释

时间:2024-01-20 20:24:21

1.json数组:jsonData。取json数组中message的appid的值。例子:

var jsonData =  {
"code":"200",
"message":"{\"appid\":\"test123\",\"data\":\"PhcDgwpfphWQMzgxmum5DwMKep2QAOqCjyyf7ltwnV/091FNi2/ERnTV92r9A154Ruo+fAK7foNaZCBXSw1IRbQ6StG/X4G+OvvOLavDiA1pRD+4hId6jDO11xTnegAllvZcAsn7jpp8ye8ewtzPpM5RJvhEzoVA\",\"signkey\":\"932ffd030344f11af5fe5a626b0e6d99\",\"url\":\"http://www.baidu?id=332503\"}"
};
var json_str = JSON.stringify(jsonData);
var json_str2 = JSON.parse(json_str);
var msg2 = json_str2.message;
var msg3 = JSON.parse(msg2);
var msg4 = msg3.appid;
console.log(msg4);