你好
我有看起来像这样的 JSON:
{
"response": {
"count": 10,
"items": [{...}, {...}, {...}, {...}]
}
}
items数组的每个元素包含或不包含copy_history数组。 通常,items 数组如下所示:
"items": [{
"id": 111,
"from_id": -119473366,
"owner_id": -119473366,
"date": 1483779506,
"marked_as_ads": 0,
"post_type": "post",
"text": "",
"copy_history": [{
"id": 30679,
"owner_id": -96126130,
"from_id": -96126130,
"date": 1483772560,
"post_type": "post",
"text": "",
"attachments": [{
"type": "photo",
"photo": {
"id": 456240780,
"album_id": -7,
"owner_id": -96126130,
"user_id": 100,
"photo_75": "https://pp.vk.me/...a3e/0zDlnwXV97M.jpg",
"photo_130": "https://pp.vk.me/...a3f/is7lDvyh3JE.jpg",
"photo_604": "https://pp.vk.me/...a40/Z6vXcOY-cf4.jpg",
"photo_807": "https://pp.vk.me/...a41/g9QedfvZoZg.jpg",
"width": 640,
"height": 521,
"text": "",
"date": 1483140936,
"post_id": 29964,
"access_key": ""
}
}]
有必要遍历每个 items 元素,从中获取 id 字段的值,并找出它是否包含copy_history数组。
请帮帮我。提前致谢
从逻辑上讲,我会这样做: