1
拨打电话时这可能是重复的 - 但我找不到解决此问题的内容。来自Google路线API的格式错误的JSON从R
我正在使用httpGET()调用google方向API。
套餐:
require(RCurl)
require(rjson)
require(gooJSON)
代码:
url = "http://maps.googleapis.com/maps/api/directions/json?origin=12.9673293,77.7173975&destination=12.9373613,77.700985&waypoints=optimize:true|12.9723379,77.7117611|12.9922162,77.715895|12.9629354,77.7122996&sensor=false"
routeJSON = httpGET(url= url)
routeList = fromJSON(routeJSON)
我得到:
Error in fromJSON(routeJSON) :
unexpected escaped character '\]' at pos 18
我写的JSON到一个文件,并将其复制到jsoneditoronline.com。我:
Error: Parse error on line 51:
... "points" : "[email protected][\]\
-----------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'
validated by jsonlint
但是,当我把网址到浏览器并复制输出到jsoneditoronline它的工作原理。
任何想法为什么它正在发生和/或如何规避它?
编辑:我试过gooJSON,但它似乎不支持地图API V3。
> goomap(url)
$Status
$Status$code
[1] 610
$Status$request
[1] "geocode"
$Status$error_message
[1] "The Geocoding API v2 has been turned down on September 9th, 2013. The Geocoding API v3 should be used now. Learn more at https://developers.google.com/maps/documentation/geocoding/"
您应该在您的帖子 – Dason
中添加您正在使用的代码包。现在就做 – jackStinger