“ routes”是一个数组,而不是using
getJSONObject,使用
getJSONArray
“腿”也是一个数组。
JSonObject jsonObject = new JSonObject(responseText);// routesArray contains ALL routesJSonArray routesArray = jsonObject.getJSonArray("routes");// Grab the first routeJSonObject route = routesArray.getJSonObject(0);// Take all legs from the routeJSonArray legs = route.getJSonArray("legs");// Grab first legJSonObject leg = legs.getJSonObject(0);JSonObject durationObject = leg.getJSonObject("duration");String duration = durationObject.getString("text");


