0
我剛與Json合作,我想從Json數組獲取特定Id數據。
這是我使用的api網址。如何通過URL過濾獲得特定的Json數據?
http://example/plapi/areas?jsoncallback=?
此URL返回JSON數組一樣
([{"area_id":"25","ca_id":"0","area_name":"Durgapuram","alias_area":"","area_spl":"No","area_lat":"16.52069","area_lng":"80.64067","area_desc":"","area_image":"","map_image":"","area_status":"1","city_id":"27","position":"0","m_keyword":""},{"area_id":"26","ca_id":"0","area_name":"Arundalpet","alias_area":"","area_spl":"No","area_lat":"16.30520","area_lng":"80.44169","area_desc":"","area_image":"","map_image":"","area_status":"1","city_id":"31","position":"0","m_keyword":""})]
在我想要得到的數據只是city_id = 31。
要獲得其ID數據爲31,我在做這樣的
var data = {
"id": "31",
};
$.getJSON("http://example/plapi/areas?jsoncallback=?",JSON.stringify(data) ,function(result){console.log(result);
});
但它返回什麼。
我想只獲得31個id關聯的數據而不是其他人。請幫我怎麼做?
是不是creal你所需要的。你需要解析json並提取一些數據,或者你需要從後端獲取一些特定的數據? – IgnazioC
我不認爲'jsoncallback'被用來定義你的查詢的'id'。 – MinusFour
上面的url返回所有區域im,具有Json數組格式,但我需要的數據只有id爲31 – user3668438