所以我在JavaScript中,需要一個用戶的照片,然後發送它關閉面部識別API的應用程序,它返回一個JSON值,然後我有轉換爲字符串。但我只有兩個返回到我的項目是important.I要拔出這兩個(UID和信心),並將它們設置爲變量;我不完全知道該怎麼做。下面是什麼是返回一個例子:如何拔出從返回JSON字符串的某些數據?
{"photos":[{"url":"http://api.skybiometry.com/fc/images/get?id=bmN2X3hybD0wMTk5c29ub3I0MXE0bjN…RyMTQzJmVxPTE1ODkmY3ZxPTY5MjcxMzEyMTI3cTImZ3Z6cmZnbnpjPTIwMTMwNDE0MTgxNjI5","pid":"[email protected]_69271312127d2","width":380,"height":300,"tags":[{"tid":"[email protected]_69271312127d2_51.05_45.67_0_1","recognizable":true,"threshold":20,"uids":[{"uid":"[email protected]","confidence":100}],"confirmed":false,"manual":false,"width":20,"height":25.33,"center":{"x":51.05,"y":45.67},"eye_left":{"x":56.32,"y":39.67},"eye_right":{"x":46.32,"y":40},"mouth_center":{"x":48.68,"y":55.67},"nose":{"x":50.79,"y":47},"yaw":0,"roll":1,"pitch":0,"attributes":{"face":{"value":"true","confidence":60}}}]}],"status":"success","usage":{"used":5,"remaining":95,"limit":100,"reset_time_text":"Sun, 14 April 2013 18:20:53 +0000","reset_time":1365963653}}
下面是代碼我目前使用的是現在返回整個字符串:
.done(function (result) {
alert("Received response..");
var resultObject = JSON.stringify(result);
alert(resultObject);
});
任何幫助,不勝感激!
http://api.jquery.com/jQuery.getJSON/已讀 – smerny
JSON.parse()來未JSON.stringify() – monkeyinsight
resultObject [ 'UID']和resultObject [ '信心']? – NINCOMPOOP