Javascript 是否有任何可公开访问的 JSON 数据源来测试真实世界的数据?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8292050/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there any publicly accessible JSON data source to test with real world data?
提问by ILya
I'm working on a JavaScript dynamically loaded tree view user control. I'd like to test it with real world data.
我正在处理 JavaScript 动态加载的树视图用户控件。我想用真实世界的数据来测试它。
Does anybody know any public service with an API that provides access to hierarchical data in JSON format?
有没有人知道任何具有 API 的公共服务,该 API 提供对 JSON 格式的分层数据的访问?
采纳答案by Alex Gray
Twitter has a public APIwhich returns JSON, for example -
Twitter 有一个返回 JSON的公共 API,例如 -
A GET
request to:
一个GET
请求:
https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=mralexgray&count=1
,
https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=mralexgray&count=1
,
EDIT:Removed due to twitter restricting their API with OAUTH
requirements...
编辑:由于 twitter 限制其 API 的OAUTH
要求而删除...
{"errors": [{"message": "The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.", "code": 68}]}
Replacing it with a simple example of the Github API- that returns a tree, of in this case, my repositories...
用Github API 的一个简单示例替换它- 返回一棵树,在这种情况下,我的存储库......
I won't include the output, as it's long.. (returns 30 repos at a time) ... But here is proof of it's tree-ed-ness.
我不会包括输出,因为它很长......(一次返回 30 个 repos)......但这里证明了它是树状的。
回答by Venusdharan
JSON Test has some
JSON 测试有一些
try its free and has other features too.
免费试用并具有其他功能。
回答by Coderer
Tumblr has a public APIthat provides JSON. You can get a dump of posts using a simple url like http://puppygifs.tumblr.com/api/read/json
.
Tumblr 有一个提供 JSON的公共 API。您可以使用像http://puppygifs.tumblr.com/api/read/json
.
回答by Braulio
Found one from Flickr that doesn't need registration / api.
从 Flickr 找到一个不需要注册/api 的。
Basic sample, Fiddle: http://jsfiddle.net/Braulio/vDr36/
基本示例,小提琴:http: //jsfiddle.net/Braulio/vDr36/
More info: post
更多信息:发布
Pasted sample
粘贴样品
HTML
HTML
<div id="images">
</div>
Javascript
Javascript
// Querystring, "tags" search term, comma delimited
var query = "http://www.flickr.com/services/feeds/photos_public.gne?tags=soccer&format=json&jsoncallback=?";
// This function is called once the call is satisfied
// http://stackoverflow.com/questions/13854250/understanding-cross-domain-xhr-and-xml-data
var mycallback = function (data) {
// Start putting together the HTML string
var htmlString = "";
// Now start cycling through our array of Flickr photo details
$.each(data.items, function(i,item){
// I only want the ickle square thumbnails
var sourceSquare = (item.media.m).replace("_m.jpg", "_s.jpg");
// Here's where we piece together the HTML
htmlString += '<li><a href="' + item.link + '" target="_blank">';
htmlString += '<img title="' + item.title + '" src="' + sourceSquare;
htmlString += '" alt="'; htmlString += item.title + '" />';
htmlString += '</a></li>';
});
// Pop our HTML in the #images DIV
$('#images').html(htmlString);
};
// Ajax call to retrieve data
$.getJSON(query, mycallback);
Another very interesting is Star Wars Rest API:
另一个非常有趣的是 Star Wars Rest API:
回答by Alex Angas
The Tumbler V2 APIprovides a pure JSON response but requires jumping through a few hoops:
该不倒翁V2 API提供了一个纯粹的JSON响应,但需要通过几个篮球跳跃:
- Register an application
- Get your "OAuth Consumer Key" which you'll find when editing your application from the apps page
- Use any of the methodsthat only require an API Key for authentication as this can be passed in the URL, e.g. posts
- Enjoy your JSON response!
Example URL: http://api.tumblr.com/v2/blog/puppygifs.tumblr.com/posts/photo?api_key=YOUR_KEY_HERE
示例网址:http: //api.tumblr.com/v2/blog/puppygifs.tumblr.com/posts/photo?api_key=YOUR_KEY_HERE
Result showing tree structure in Fiddler:
结果显示Fiddler 中的树结构: