我正在尝试解析来自各种来源的 rss 提要,其中一个来源是:http://feeds.feedburner.com/DiscoveryNews-Top-Stories
但是这个来源给了我一些奇怪的 json 数据,如下所示:
"item": [
{
"title": [
"Snazzy Science Photos of the Week (August 10-16)",
{
"type": "html",
"content": "Snazzy Science Photos of the Week (August 10-16)"
}
],
"description": [
"Glowing rabbits, treasure-hunting badgers and a case of mistaken UFO identity help round out this week's photos.<img src=\"http://feeds.feedburner.com/~r/DiscoveryNews-Top-Stories/~4/S6Urfvdw2DQ\" height=\"1\" width=\"1\"/>",
{
"type": "html",
"content": "Glowing rabbits, treasure-hunting badgers and a case of mistaken UFO identity help round out this week's photos."
}
],
目前,我正在使用以下代码来获取帖子的标题:
if(isset($jit->title->content)){
$title = $decoded_json->query->results->item->title->content;
}else{
$title = $decoded_json->query->results->item->title;
}
但是当我尝试解析 Discovery 新闻提要时,上面的代码失败了。请帮忙?
[编辑]:我正在使用 YQL 从源代码中获取等效的 JSON。这是链接