繁体   English   中英

使用jquery从JSON数据中提取并记录值

[英]extract and log a value from JSON data using jquery

我进行了搜索,但是不确定如何表达我的查询,我一直无法实现我认为的简单目标。

我有一个通过Yahoo Pipes运行的Deviant Art的RSS feed

这是管道” http://pipes.yahoo.com/pipes/pipe.info?_id=63478be58fb00758ded9d5108170f931

管道生成的JSON http://pipes.yahoo.com/pipes/pipe.run?_id=63478be58fb00758ded9d5108170f931&_render=json看起来像这样:

{"url":"http:\\/\\/darksilverflame.deviantart.com","content":"Copyright 2012 *DarkSilverflame","description":null,"title":null}, ....... 。

我想要实现的是一种简单的方法,该方法通过jquery(或只是JS)解析数据,然后从Deviant Art和指向这些用户页面的链接中生成一个简单的用户名txt列表。

您可以使用 :

jQuery.parseJSON(json) 链接到jQuery Documentaion

parsedObject =jQuery.parseJSON( '{"url":"http:\/\/darksilverflame.deviantart.com","content":"Copyright 2012 *DarkSilverflame","description":null,"title":null}');

或使用Chrome(F12->控制台,然后测试以下内容)

  a = JSON.parse('{"url":"http:\/\/darksilverflame.deviantart.com","content":"Copyright 2012 *DarkSilverflame","description":null,"title":null}');

希望对您有所帮助。

进一步了解Mehdi的答案:如果您正在寻找一种简单的方法来一步一步地检索和处理数据,则可以从通常的方法开始:

$ .getJSON('http://pipes.yahoo.com/pipes/pipe.run?_id=63478be58fb00758ded9d5108170f931&_render=json',function(data){$ .each(data.items,function(i,item){//在这里做些事}});

http://docs.jquery.com/Ajax/jQuery.getJSON

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM