【发布时间】:2015-04-18 18:44:33
【问题描述】:
您好,我有一个来自 $resource 请求的 json 数据,我需要将其解析为数组,以便遍历其属性。任何帮助将不胜感激。
{
"feed": {
"author": {
"name": {
"label": "iTunes Store"
},
"uri": {
"label": "http://www.apple.com/itunes/"
}
},
"entry": [
{
"im:name": {
"label": "Paddington"
},
"im:image": [
{
"label": "url1",
"attributes": {
"height": "60"
}
},
{
"label": "url2",
"attributes": {
"height": "60"
}
},
{
"label": "url3",
"attributes": {
"height": "170"
}
}
]
},
{
"im:name": {
"label": "Interstellar"
},"im:image": [
{
"label": "url4",
"attributes": {
"height": "60"
}
},
{
"label": "url5",
"attributes": {
"height": "60"
}
},
{
"label": "url6",
"attributes": {
"height": "170"
}
}
]
}
],
"updated": {
"label": "2015-04-18T11:29:36-07:00"
},
"rights": {
"label": "Copyright 2008 Apple Inc."
},
"title": {
"label": "iTunes Store: Top Movies"
}
}
}
我需要填充标签和网址
app.factory('movieService',function ($resource) {
return $resource('https://itunes.apple.com/us/rss/topmovies/limit=50/genre=:id/json', {id: '@id'});
});
谢谢
【问题讨论】:
-
我相信你可以做到
JSON.parse(object) -
你能给我举个例子吗?
-
你尝试了什么?我们可以“帮助”您,而不是为您编写代码。
标签: javascript jquery json angularjs angularjs-ng-repeat