gpt4 book ai didi

jquery - 如何解析 tumblr JSON 提要

转载 作者:行者123 更新时间:2023-12-01 06:37:47 24 4
gpt4 key购买 nike

我需要从此 JSON feed 获取常规标题和常规正文。我尝试了各种方法但收效甚微。大家有解决办法吗?

http://clintonbeattie.tumblr.com/bio/json

谢谢,

最佳答案

这不是 JSON,这是对 JSONP 的奇怪看法。

如果添加 <script />带有 src 的标签设置为http://clintonbeattie.tumblr.com/bio/json ,全局变量tumblr_api_read将指向一个带有响应信息的对象;

var tumblr_api_read = {
"tumblelog": {
"title": "First Title",
"description": "",
"name": "clintonbeattie",
"timezone": "US\/Eastern",
"cname": false,
"feeds": []
},
"posts": [{
"id": null,
"url": "",
"url-with-slug": "",
"type": "regular",
"date-gmt": " GMT",
"date": "Wed, 31 Dec 1969 19:00:00",
"bookmarklet": null,
"mobile": null,
"feed-item": "",
"from-feed-id": 0,
"unix-timestamp": 1333622193,
"format": "html",
"reblog-key": "TmN3ujDJ",
"slug": "",
"regular-title": "",
"regular-body": ""
}]
};

因此做这样的事情;

<script src="http://clintonbeattie.tumblr.com/bio/json"></script>
<script>
// Use tumblr_api_read.

alert(tumblr_api_read.tumblelog.title); // Shows "First Title"

for (var i=0;i<tumblr_api_read.posts.length;i++) {
var thisPost = tumblr_api_read.posts[i];

alert("This post was created at " + thisPost.date);
}
</script>

关于jquery - 如何解析 tumblr JSON 提要,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10030646/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com