我正在尝试查找jsonObject距离中的值(即 10194)
{
"destination_addresses" : [ "Burnaby, BC, Canada" ],
"origin_addresses" : [ "Vancouver, BC, Canada" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "10.2 km",
"value" : 10194
},
"duration" : {
"text" : "19 mins",
"value" : 1118
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}
我写了这段代码,但它给了我 null
rows = jObj.getJSONObject(TAG_ROWS);
JSONArray elements = new JSONArray (rows.getString(TAG_ELEMENTS));
for (int i=0; i<elements.length();i++){
JSONObject obj = elements.optJSONObject(i);
JSONObject distance = obj.getJSONObject(TAG_DISTANCE);
value= distance.getString(TAG_VALUE);
任何的想法 ??