Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用jqueryeach解析googlereader starred.json_Jquery_Json_Google Reader - Fatal编程技术网

使用jqueryeach解析googlereader starred.json

使用jqueryeach解析googlereader starred.json,jquery,json,google-reader,Jquery,Json,Google Reader,我在解析google reader导出中的starred.json文件以将其转换为html文件以导入getpocket时遇到问题 使用jqueryeach,我没有将starred.json的内容粘贴到这里,因为它太大了 问题是数组和对象的混合 我正在尝试获取url、标题和摘要 var data = { "id" : "user/17115776656148603551/state/com.google/starred", "title" : "Dasa סימן פריטים ב

我在解析google reader导出中的starred.json文件以将其转换为html文件以导入getpocket时遇到问题

使用jqueryeach,我没有将starred.json的内容粘贴到这里,因为它太大了

问题是数组和对象的混合

我正在尝试获取url、标题和摘要

    var data = {
  "id" : "user/17115776656148603551/state/com.google/starred",
  "title" : "Dasa סימן פריטים בכוכב ב-Google Reader",
  "author" : "Dasa",
  "updated" : 1368699933,
  "direction" : "ltr",
  "items" : [ {
    "crawlTimeMsec" : "1368699933957",
    "timestampUsec" : "1368699933957939",
    "id" : "tag:google.com,2005:reader/item/eb307953496c3755",
    "categories" : [ "user/17115776656148603551/state/com.google/starred", "user/17115776656148603551/state/com.google/fresh", "search", "job search", "news stories", "trending", "job hunting", "news", "vanity searches", "productivity", "search query", "google alerts", "alerts", "organization", "local news", "google", "time savers", "trending news", "shortcuts", "notifications" ],
    "title" : "Five Creative Uses for Google Alerts",
    "published" : 1366282800,
    "updated" : 1366282800,
    "canonical" : [ {
      "href" : "http://lifehacker.com/five-creative-uses-for-google-alerts-475278626"
    } ],
    "alternate" : [ {
      "href" : "http://feeds.gawker.com/~r/lifehacker/full/~3/jaLbxODg6SM/five-creative-uses-for-google-alerts-475278626",
      "type" : "text/html"
    } ],
    "summary" : {
      "direction" : "ltr",
      "content" : "<p><img height=\"360\" width=\"640\" src=\"http://img.gawkerassets.com/img/18kye9icys64djpg/ku-xlarge.jpg\"></p><p>Google Alerts is one of Google's hidden gems. It's a really powerful tool to keep track of trends, interesting topics, or anything really new that appears on the web. If you're not using it already, here are a few creative ways to get started with it.</p><p><a href=\"http://lifehacker.com/five-creative-uses-for-google-alerts-475278626\">Read more...</a></p><img width=\"1\" height=\"1\" src=\"http://lifehacker.feedsportal.com/c/34977/f/647165/s/2add7ec3/mf.gif\" border=\"0\"><div><table border=\"0\"><tr><td valign=\"middle\"><a href=\"http://share.feedsportal.com/share/twitter/?u=http%3A%2F%2Flifehacker.com%2Ffive-creative-uses-for-google-alerts-475278626&amp;t=Five+Creative+Uses+for+Google+Alerts\"><img src=\"http://res3.feedsportal.com/social/twitter.png\" border=\"0\"></a> <a href=\"http://share.feedsportal.com/share/facebook/?u=http%3A%2F%2Flifehacker.com%2Ffive-creative-uses-for-google-alerts-475278626&amp;t=Five+Creative+Uses+for+Google+Alerts\"><img src=\"http://res3.feedsportal.com/social/facebook.png\" border=\"0\"></a> <a href=\"http://share.feedsportal.com/share/linkedin/?u=http%3A%2F%2Flifehacker.com%2Ffive-creative-uses-for-google-alerts-475278626&amp;t=Five+Creative+Uses+for+Google+Alerts\"><img src=\"http://res3.feedsportal.com/social/linkedin.png\" border=\"0\"></a> <a href=\"http://share.feedsportal.com/share/gplus/?u=http%3A%2F%2Flifehacker.com%2Ffive-creative-uses-for-google-alerts-475278626&amp;t=Five+Creative+Uses+for+Google+Alerts\"><img src=\"http://res3.feedsportal.com/social/googleplus.png\" border=\"0\"></a> <a href=\"http://share.feedsportal.com/share/email/?u=http%3A%2F%2Flifehacker.com%2Ffive-creative-uses-for-google-alerts-475278626&amp;t=Five+Creative+Uses+for+Google+Alerts\"><img src=\"http://res3.feedsportal.com/social/email.png\" border=\"0\"></a></td></tr></table></div><br><br><a href=\"http://da.feedsportal.com/r/163644809562/u/49/f/647165/c/34977/s/2add7ec3/kg/342/a2.htm\"><img src=\"http://da.feedsportal.com/r/163644809562/u/49/f/647165/c/34977/s/2add7ec3/kg/342/a2.img\" border=\"0\"></a><img width=\"1\" height=\"1\" src=\"http://pi.feedsportal.com/r/163644809562/u/49/f/647165/c/34977/s/2add7ec3/kg/342/a2t.img\" border=\"0\"><img src=\"http://feeds.feedburner.com/~r/lifehacker/full/~4/jaLbxODg6SM\" height=\"1\" width=\"1\">"
    },
    "author" : "Alan Henry",
    "comments" : [ ],
    "annotations" : [ ],
    "origin" : {
      "streamId" : "feed/http://lifehacker.com/index.xml",
      "title" : "Lifehacker",
      "htmlUrl" : "http://lifehacker.com"
    }
  }, {
    "crawlTimeMsec" : "1368699816215",
    "timestampUsec" : "1368699816215241",
    "id" : "tag:google.com,2005:reader/item/84c25c636b707078",
    "categories" : [ "user/17115776656148603551/state/com.google/read", "user/17115776656148603551/state/com.google/starred", "user/17115776656148603551/state/com.google/fresh", "Breakfast", "Gluten-Free", "Photo", "Pudding" ],
    "title" : "yogurt panna cotta with walnuts and honey",
    "published" : 1366988860,
    "updated" : 1366988860,
    "canonical" : [ {
      "href" : "http://smittenkitchen.com/blog/2013/04/yogurt-panna-cotta-with-walnuts-and-honey/"
    } ],
    "alternate" : [ {
      "href" : "http://feedproxy.google.com/~r/smittenkitchen/~3/t_w8asbkyNg/",
      "type" : "text/html"
    } ],
    "content" : {
      "direction" : "ltr",
      "content" : "<p><a href=\"http://smittenkitchen.com/blog/2013/04/yogurt-panna-cotta-with-walnuts-and-honey/\" title=\"yogurt panna cotta with walnuts and honey\"><img src=\"http://farm9.staticflickr.com/8400/8682467912_efaa762c89.jpg\" width=\"500\" height=\"333\" alt=\"yogurt panna cotta with walnuts and honey\"></a></p>\nGuys, I just discovered the ultimate weekend brunch treat/decadent dessert that still contains a whiff of moderation/<a href=\"http://www.flickr.com/photos/smitten/8681658077/in/photostream\">preschooler</a> snack. The ingredient list is so short, and the cooking process is so simple that you’ll have the recipe memorized by the time you make it the second time. And you will make it a second time, maybe even within a week. It looks pretty, tastes luxurious and… well, most of you probably discovered panna cotta a decade ago.\n<p><a href=\"http://www.flickr.com/photos/smitten/8682466230/\" title=\"lemon, gelatin, sugar, milk/cream, yogurt\"><img src=\"http://farm9.staticflickr.com/8395/8682466230_9e19d63848.jpg\" width=\"500\" height=\"333\" alt=\"lemon, gelatin, sugar, milk/cream, yogurt\"></a><br>\n<a href=\"http://www.flickr.com/photos/smitten/8682466352/\" title=\"thick greek yogurt\"><img src=\"http://farm9.staticflickr.com/8262/8682466352_5a3120eb08.jpg\" width=\"500\" height=\"333\" alt=\"thick greek yogurt\"></a></p>\n<p>I’m sorry, I’m just slow. For example, this week I started reading <a href=\"http://www.amazon.com/gp/product/1594483299/ref=as_li_ss_tl?ie=UTF8&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1594483299&amp;linkCode=as2&amp;tag=smitten-20\">this new book</a> that everyone was talking about in September … 2007. And that’s just the beginning. Gallery wall? Skinny jeans? Arrested Development? Quinoa? People, I am <i>on it</i>. True to sluggish form, it’s been a full four years since my friend Nicole gushed to me about the wonders of yogurt panna cotta. I put it on my cooking to-do list, blinked, and that about brings us up to last week when I saw it on my list and thought, “right, wasn’t I going to make that a few days ago?”</p>\n<p><a href=\"http://www.flickr.com/photos/smitten/8681355169/\" title=\"yogurt whisked with milk or cream\"><img src=\"http://farm9.staticflickr.com/8522/8681355169_9657d4a377.jpg\" width=\"500\" height=\"333\" alt=\"yogurt whisked with milk or cream\"></a></p>\n<p><b>... Read the rest of <a href=\"http://smittenkitchen.com/blog/2013/04/yogurt-panna-cotta-with-walnuts-and-honey/\">yogurt panna cotta with walnuts and honey</a> on <a href=\"http://smittenkitchen.com\">smittenkitchen.com</a></b></p>\n<hr>\n<p><small>© smitten kitchen 2006-2012. |\n<a href=\"http://smittenkitchen.com/blog/2013/04/yogurt-panna-cotta-with-walnuts-and-honey/\">permalink to <b>yogurt panna cotta with walnuts and honey</b></a> | <a href=\"http://smittenkitchen.com/blog/2013/04/yogurt-panna-cotta-with-walnuts-and-honey/#comments\">220 comments</a> to date | see more: <a href=\"http://smittenkitchen.com/blog/category/breakfast/\" title=\"View all posts in Breakfast\" rel=\"category tag\">Breakfast</a>, <a href=\"http://smittenkitchen.com/blog/category/gluten-free/\" title=\"View all posts in Gluten-Free\" rel=\"category tag\">Gluten-Free</a>, <a href=\"http://smittenkitchen.com/blog/category/photo/\" title=\"View all posts in Photo\" rel=\"category tag\">Photo</a>, <a href=\"http://smittenkitchen.com/blog/category/pudding/\" title=\"View all posts in Pudding\" rel=\"category tag\">Pudding</a>\n</small></p>"
    },
    "author" : "deb",
    "comments" : [ ],
    "annotations" : [ ],
    "origin" : {
      "streamId" : "feed/http://feeds.feedburner.com/smittenkitchen",
      "title" : "smitten kitchen",
      "htmlUrl" : "http://smittenkitchen.com"
    }
  } ]
}


    $(document).ready(function() {


            var output='<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Instapaper: Export</title></head><body><h1>Unread</h1><ol></ol><h1>Archive</h1><ol>';

                $.each(data.items, function(i, data){
                output+='<li><a href="'+ data['title'] + '">'+ data['title'] + data['canonical'].href + '</li>:';
                });   

            output+='</ol></body></html>';
            document.getElementById("placeholder").innerHTML=output;
    });

        </script>
var数据={
“id”:“user/17115776656148603551/state/com.google/starred”,
“标题”:“谷歌阅读器”,
“作者”:“Dasa”,
“更新”:1368699933,
“方向”:“ltr”,
“项目”:[{
“爬行时间毫秒”:“1368699933957”,
“timestampUsec”:“136869993957939”,
“id”:“tag:google.com,2005:reader/item/eb307953496c3755”,
“类别”:[“user/1711577665648603551/state/com.google/starred”、“user/1711577665648603551/state/com.google/fresh”、“搜索”、“求职”、“新闻故事”、“趋势”、“求职”、“新闻”、“虚荣搜索”、“生产力”、“搜索查询”、“谷歌警报”、“警报”、“组织”、“本地新闻”、“谷歌”、“省时”、“趋势新闻”,“快捷方式”、“通知”],
“标题”:“谷歌警报的五种创造性用途”,
“已出版”:1366282800,
“更新”:1366282800,
“规范的”:[{
“href”:”http://lifehacker.com/five-creative-uses-for-google-alerts-475278626"
} ],
“候补”:[{
“href”:”http://feeds.gawker.com/~r/lifehacker/full/~3/jaLbxODg6SM/five-creative-uses-for-google-alerts-475278626“,
“类型”:“文本/html”
} ],
“摘要”:{
“方向”:“ltr”,
“内容”:“

谷歌提醒是谷歌隐藏的宝藏之一。它是一个非常强大的工具,可以跟踪趋势、有趣的话题或任何出现在web上的新事物。如果您还没有使用它,这里有一些创造性的方法开始使用它。



” }, “作者”:“艾伦·亨利”, “评论”:[…], “注释”:[], “起源”:{ “streamId”:“提要”/http://lifehacker.com/index.xml", “头衔”:“生活黑客”, “htmlUrl”:http://lifehacker.com" } }, { “爬行时间毫秒”:“1368699816215”, “timestampUsec”:“1368699816215241”, “id”:“tag:google.com,2005:reader/item/84C25C636B7078”, “类别”:[“user/1711577665648603551/state/com.google/read”,“user/1711577666148603551/state/com.google/starred”,“user/1711577665648603551/state/com.google/fresh”,“早餐”,“无麸质”,“照片”,“布丁”], “标题”:“核桃和蜂蜜酸奶panna cotta”, “已出版”:1366988860, “更新”:1366988860, “规范的”:[{ “href”:”http://smittenkitchen.com/blog/2013/04/yogurt-panna-cotta-with-walnuts-and-honey/" } ], “候补”:[{ “href”:”http://feedproxy.google.com/~r/smittenkitchen/~3/t_w8asbkyNg/“, “类型”:“文本/html” } ], “内容”:{ “方向”:“ltr”, “内容”:

\n哎呀,我刚刚发现了周末的终极早午餐款待/颓废甜点,它仍然含有一点适度/零食的味道。配料表很短,烹饪过程很简单,你在第二次做的时候就能记住食谱。而且你会第二次做,甚至可能在一周内。它看起来很漂亮,味道很豪华,而且……嗯,你们中的大多数人可能在十年前就发现了潘娜·科塔。\n
\n

\n对不起,我只是反应迟钝。例如,本周我开始读到大家都在谈论的2007年9月……那只是个开始。画廊墙?紧身牛仔裤?发展受阻?奎奴亚藜?人们,我我在上面。我的朋友妮可向我滔滔不绝地讲述酸奶潘娜库塔的神奇之处已经整整四年了。我把它放在了我的烹饪清单上,眨了眨眼,这让我们想起了上周我在清单上看到它的时候,我想,“好吧,几天前我不是要做这个吗?”

\n\n..阅读

\n
\n©smitten kitchen 2006-2012的其余部分。| \n |迄今为止|请参阅更多信息:,\n

” }, “作者”:“deb”, “评论”:[…], “注释”:[], “起源”:{ “streamId”:“提要”/http://feeds.feedburner.com/smittenkitchen", “标题”:“被击倒的厨房”, “htmlUrl”:http://smittenkitchen.com" } } ] } $(文档).ready(函数(){ var output='Instapaper:ExportUnderChive'; $.each(data.items,function(i,data){ 输出+='
  • '+数据['title']+数据['canonical'].href+'
  • :'; }); 输出+=''; document.getElementById(“占位符”).innerHTML=输出; });
    您可以通过以下方式访问所需的属性:

    var title = data.title,
        url = data.canonical[0].href,
        summary = data.summary.content;
    

    或者,您可以使用“this”而不是“data”,这可能会使代码更容易理解,因为“data”在其他地方的使用方式不同。

    我们需要
    STARRED>JSON内容在这里的样子,否则我们无法帮到您。@TryingToImprove STARRED.JSON添加的内容。首先,有一个错误的结尾在那个长长的“内容”字段中,它写着这本新书,应该是
    click/1594483299>\“>这本新书
    。我不知道这是否是问题所在。@Aioros不,这不是问题所在这可能是正确的解决方案,我只认为你应该用
    数据
    来更改
    这个
    ,只是为了清楚起见,因为这是问题中使用的名称。@RobJ我得到了未捕获的语法错误:意外的标记其他是JSON本身的语法错误。如果您使用的是IDE,它应该为您突出显示错误。寻找未替换的引用等(请参阅问题下方Aioros的评论)。这应该可以解决任何问题。此外,如果在屏幕上显示,您应该过滤摘要,以确保它们不包含任何不受欢迎的脚本标记等等。@Robj我想这是必须的