因此,我正在使用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