我想在JSON數據中搜索對象的屬性。長度沒有在jQuery中定義
但我在jQuery中遇到類似uncaught type error:length is not defined
的錯誤。我的JSON看起來像這樣:
var list = {
meta: {
limit: 1000,
offset: 0,
previous: null,
total_count: 1797
},
objects: [{
id: 1215,
location: {
id: 1306,
name: "Austin",
parent_id: 43,
type: "City",
},
name: "2ND Street District",
}]
};
$.each(list.objects.location, function (i, v) {
if (v.id.search(new RegExp(/1036/i)) != -1) {
alert(v.name);
return;
}
});
給我關於這個問題的任何想法。
發佈了一個答案。希望它解決了你的問題。看看 – iJade