Read JSON data returned by google maps
In my app I use the BlackBerry API to get latitude and longitude. I would like to do reverse geocoding using Google maps by creating an http connection. How do I parse the data, and then read a specific element, such as the address?
An example URL:
http://maps.google.com/maps/geo?json&ll=9.6,73.7
Gives response:
{
"name": "9.600000,76.760000",
"Status": {
"code": 200,
"request": "geocode"
开发者_运维技巧 },
"Placemark": [ {
"id": "p1",
"address": "Kanjirappalli Elikkulam Rd, Kerala, India",
"AddressDetails": {
"Accuracy" : 6,
"Country" : {
"AdministrativeArea" : {
"AdministrativeAreaName" : "Kerala",
"SubAdministrativeArea" : {
"SubAdministrativeAreaName" : "Kottayam",
"Thoroughfare" : {
"ThoroughfareName" : "Kanjirappalli Elikkulam Rd"
}
}
},
"CountryName" : "India",
"CountryNameCode" : "IN"
}
Use the JSON ME library. See Using JSON in Java ME for examples of how to use it.
精彩评论