私はJSONに慣れていないので、主にPHPを実行します。 MapquestジオコーディングAPIにクエリを実行すると、PHPでjson_decodeしようとすると「NULL」になる次のjson文字列が取得されます。 JSONLintを通してそれを実行JSON構文の問題
renderOptions({
"info": {
"statuscode": 0,
"copyright": {
"text": "\u00A9 2016 MapQuest, Inc.",
"imageUrl": "https://api.mqcdn.com/res/mqlogo.gif",
"imageAltText": "\u00A9 2016 MapQuest, Inc."
},
"messages": []
},
"options": {
"maxResults": -1,
"thumbMaps": true,
"ignoreLatLngInput": false
},
"results": [{
"providedLocation": {
"street": "Kingston Upon Thames,uk"
},
"locations": [{
"street": "",
"unknownInput": "",
"type": "s",
"latLng": {
"lat": 51.409628,
"lng": -0.306262
},
"displayLatLng": {
"lat": 51.409628,
"lng": -0.306262
},
"mapUrl": "https://open.mapquestapi.com/staticmap/v4/getmap?key=na&type=map&size=225,160&pois=purple-1,51.4096275,-0.3062621,0,0,|¢er=51.4096275,-0.3062621&zoom=12&rand=54353"
}]
}]
})
、私は次のエラーを取得する:
Error: Parse error on line 1: renderOptions({ "in^Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'
私は私がしてきた修正が非常に簡単ですが、私はJSONの構文のあまり意識していないよ想像します'renderOptions'の前に物を置いてぼんやりと動く。
問題を修正する正しい構文は何ですか?
http://stackoverflow.com/questions/2887209/what-are-the-differences-between-json-and-jsonp – michaJlS
JSONではなくJSONPが返されています。上のコメントに掲載されたリンクを読んで、代わりにJSONを取り戻す方法に関するMapquestのドキュメントを見てください。 – JAAulde