如何從此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