如何从此JSON字符串中获取特定值。我想获得嵌套的嵌套JSON对象"FromUserId": "bd079f57"
并将其传递给Javascript函数。如何从JSON字符串中读取特定字符串对象
"notification":{
"title" :"Test",
"message" : "Message",
"android": {
"data": {
"priority": "2",
"profile": "profile",
"message": "xxx has sent you a Message.",
"style": "inbox",
"noteId": "1",
"visibility": "1",
"title": "Test",
"badge": "12",
"FromUserId": "bd079f57"
}
}
}
"onNotification": function (notification) {
var obj = JSON.parse(notification.message.android.data.FromUserId);
// How to pass this test.FromUserId to ReadData function.
ReadData(obj)
}
$scope.ReadData(obj){
//further process of json
}
VAR OBJ = JSON.parse(试验); ReadData(test.notification.android.data.FromUserId); 虽然我不是100%确定你的json是有效的,但我认为它并不像上面那样。 –
你收到字符串了吗?如果是,然后解析它像'JSON.prase(_your_json)',然后'notification.android.data.FromUserId'? – Rahul
JSON.parse(notification.FromUserId)应该是JSON.parse(通知) – james