Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/05/2012, 22:24
Fsg
 
Fecha de Ingreso: junio-2009
Mensajes: 155
Antigüedad: 14 años, 10 meses
Puntos: 5
Pregunta Problema con JSONArray en Java

Hola a todos.
Vengo con un problema con un codigo que he encontrado para trabajar en Android, lo pongo aca ya que creo no es referente a algo directamente con Android ,siento que es cuestion de sintaxis.

Tengo un codigo, basicamente es un metodo que me permite separar un JSONObject y pasar valores algunos valores a variables de tipo double:


Double lon = new Double(0);
Double lat = new Double(0);
public void getGeoPoint(JSONObject jsonObject) {


try {

lon = ((JSONArray)jsonObject.get("results")).getJSONObje ct(0)
.getJSONObject("geometry").getJSONObject("location ")
.getDouble("lng");

lat = ((JSONArray)jsonObject.get("results")).getJSONObje ct(0)
.getJSONObject("geometry").getJSONObject("location ")
.getDouble("lat");

} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


}

El problema lo tengo en estas lineas:

lon = ((JSONArray)jsonObject.get("results")).getJSONObje ct(0)
.getJSONObject("geometry").getJSONObject("location ")
.getDouble("lng");

y esta:

lat = ((JSONArray)jsonObject.get("results")).getJSONObje ct(0)
.getJSONObject("geometry").getJSONObject("location ")
.getDouble("lat");
Y el error que obtengo es el siguiente:

JSONArray cannot be resolved
to a type

Al parecer es la cuestion de el intento de realizar un cast a JSONArray, intente buscar si a lo mejor tenia algo que importar para que funcionara, pero he usado muy poco este tipo de conversiones.
No pongo el otro metodo, ya que el otro metodo no tengo ningun problema, ¿alguien sabe que puede ser?