Hoc Gioi Toan

Saturday, June 9, 2012

Parse Json goolge map to lat & longi


//get json
String responseBody = httpclient.execute(httppost,
responseHandler);
//convert to oject
JSONObject json = new JSONObject(responseBody);
JSONArray jArray = json.getJSONArray("results");

JSONObject json2 = jArray.getJSONObject(0);
//get object geometry
JSONObject json3 = json2.getJSONObject("geometry");

try
{
//if bounds
JSONObject e = json3.getJSONObject("bounds");
String s = e.getString("northeast");
jObject = new JSONObject(s);
}
catch (Exception e) {
//if location
// TODO: handle exception
JSONObject e2 = json3.getJSONObject("location");
String s2 = e2.getString("northeast");
jObject = new JSONObject(s2);
}

Download

No comments:

Post a Comment