さまざまなソースからの RSS フィードを解析しようとしていますが、そのようなソースの 1 つがこれです: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 ニュース フィードを解析しようとすると、上記のコードは失敗します。
[編集]: ソースから同等の JSON を取得するために YQL を使用しています。これはリンクです