如何从 json google places api 中检索“locality”
在这个 json 响应中:
{
"html_attributions" : [],
"result" : {
"address_components" : [
{
"long_name" : "1623",
"short_name" : "1623",
"types" : [ "street_number" ]
},
{
"long_name" : "1/2 N Cahuenga Boulevard",
"short_name" : "1/2 N Cahuenga Boulevard",
"types" : [ "route" ]
},
{
"long_name" : "Los Angeles",
"short_name" : "Los Angeles",
"types" : [ "locality", "political" ]
},
{
"long_name" : "CA",
"short_name" : "CA",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "US",
"short_name" : "US",
"types" : [ "country", "political" ]
},
{
"long_name" : "90028",
"short_name" : "90028",
"types" : [ "postal_code" ]
}
我正在使用此代码来获取“lat”和“lng”:
JSONObject jsonLocation = c.getJSONObject("geometry").getJSONObject("location");
places_latitude = jsonLocation.getString("lat");
places_longitude = jsonLocation.getString("lng");
我如何获得“位置”值?我正在使用java。
谢谢,
卡洛斯。