因此,我正在使用angular制作混合移动应用程序,并且我有来自$ http.jsonp请求的此字符串。我收到的回复正在尝试转入JSON。我在https://jsonformatter.curiousconcept.com/上检查过JSON请求,看起来JSON是有效的。努力将JavaScript中的JSON字符串转换为JSON
我在Chrome Web控制台收到的错误是“未捕获的语法错误:意外的令牌:”,我不能为我的生活找出原因吗?
使用以下服务器的响应,有人能告诉我我在做什么错吗?
{
"rss":{
"version":"2.0",
"xmlns:content":"http://purl.org/rss/1.0/modules/content/",
"xmlns:wfw":"http://wellformedweb.org/CommentAPI/",
"xmlns:dc":"http://purl.org/dc/elements/1.1/",
"xmlns:atom":"http://www.w3.org/2005/Atom",
"xmlns:sy":"http://purl.org/rss/1.0/modules/syndication/",
"xmlns:slash":"http://purl.org/rss/1.0/modules/slash/",
"channel":{
"title":"WEBSITE TITLE",
"link":[
{
"href":"https://www.WEBURL.com/feed/",
"rel":"self",
"type":"application/rss+xml"
},
"https://www.WEBURL.com"
],
"description":"WEB DESCRIPTION",
"lastBuildDate":"Fri, 25 Sep 2015 16:33:52 +0000",
"language":"en-US",
"updatePeriod":"hourly",
"updateFrequency":"1",
"generator":"http://wordpress.org/?v=4.3",
"item":[
{
"title":"TITLE",
"link":"https://www.WEBURL.com/2015/09/25/POST",
"comments":[
"https://www.WEBURL.com/2015/09/25/POST/#comments",
"0"
],
"pubDate":"Fri, 25 Sep 2015 16:27:19 +0000",
"creator":"AUTHOR",
"category":"CATEGORY",
"guid":"https://www.WEBURL.com/?p=12345",
"description":"<p>POST DESCRIPTION</p>\n",
"encoded":"<p class=\"article-content__figure article-content--image\">POST CONTENT</p>\n",
"commentRss":"https://www.WEBURL.com/2015/09/25/POST/feed/"
}
]
}
}
}
的JavaScript去为:
$http.jsonp("http://jsonburner.herokuapp.com/source?feed=https://www.WEBURL.com/feed/")
.success(function(data) {
$scope.debug = data.rss.version
//$scope.debug = data.rss.version
})
.error(function(data) {
$scope.debug = data
//$scope.debug = data.rss.version
});
感谢
亚历
我试图在浏览器中的资讯提供网址,它给出了一个错误。我认为这是json不能正确解析的原因。 – Sachin
您的代码无法以任何可能的格式生效。你看起来像是从Angular代码复制的,然后是一个与更多的Angular代码混合的URL。 – ydaniv