【发布时间】:2015-03-30 09:58:08
【问题描述】:
我正在使用网络服务http://maps.google.com/maps/api/geocode/json?address=mysore 在我的 plsql 代码中获取位置数据。我可以使用work with json in oracle 的帮助访问第一级数据。但这有助于从 json 获取第一级数据。
我需要进一步获取 lat 和 lng 值。谁能帮我解决这个问题?
Location = {
"bounds" : {
"northeast" : {
"lat" : 44.9483849,
"lng" : -93.1261959
},
"southwest" : {
"lat" : 44.9223829,
"lng" : -93.200307
}
},
"location" : {
"lat" : 44.9330076,
"lng" : -93.16290629999999
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 44.9483849,
"lng" : -93.1261959
},
"southwest" : {
"lat" : 44.9223829,
"lng" : -93.200307
}
}
}
这是我从 google maps api 获取地址的代码。我需要从响应中获取纬度、经度和 formatted_address。
CREATE OR REPLACE PROCEDURE geo_lat_long_addr_proc(
ADDRESS VARCHAR2 DEFAULT 'EUR')
IS
v_debug_mode BOOLEAN := TRUE;
v_req utl_http.req;
v_resp utl_http.resp;
v_msg VARCHAR2(80);
v_entire_msg VARCHAR2(32767) := NULL;
v_conversion_factor NUMBER;
v_url VARCHAR2(256) :=
'http://maps.google.com/maps/api/geocode/json?address='||
ADDRESS
;
BEGIN
v_req := utl_http.begin_request(url => v_url,
method => 'GET');
v_resp := utl_http.get_response(r => v_req);
IF v_debug_mode
THEN
dbms_output.put_line('HTTP Status Return code: '||
v_resp.status_code);
END IF;
BEGIN
LOOP
utl_http.read_text(r => v_resp,data => v_msg);
v_entire_msg := v_entire_msg||v_msg;
END LOOP;
EXCEPTION
WHEN utl_http.end_of_body
THEN null;
END;
IF v_debug_mode
THEN dbms_output.put_line(v_entire_msg);
END IF;
utl_http.end_response(r => v_resp);
EXCEPTION
WHEN others
THEN RETURN;
END geo_lat_long_addr_proc;
/
【问题讨论】:
-
我在您的示例中看不到任何 pljson 代码。这个问题和pljson有什么关系?
标签: json parsing plsql tree pljson