我有这个数组:
[{
"title": "Pirates of the Caribbean 5",
"others": "lorem",
"tags": "action,experimental,comedy"
},
{
"title": "Toy Story 3",
"others": "lorem",
"tags": "animation,family,comedy"
},
{
"title": "Pirates of the Caribbean 1",
"others": "lorem",
"tags": "action,adventure,comedy"
}]
我正在尝试获取标签为action的所有详细信息(标题,其他) 。
要查找字符串是否包含操作,我这样做:
$.getJSON('jsonpath.json', function(data) {
var items = [];
$.each(data, function(count,item) {
var a = $.inArray("action", item.tags.split(","));
if (a != -1){
console.log("Found")
}
});
});
在这里之后我该怎么做才能附加/解析标题和其他带有动作标签的电影?