나는 안드로이드 프로그래밍에 익숙하지 않으며 JSONarray에서 특정 객체를 얻는 방법을 알고 싶습니다.json 배열에서 JSONObject를 얻을 수있는 방법
{"results" : [
{
"address_components" : [
{
"long_name" : "Contern",
"short_name" : "Contern",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Luxembourg",
"short_name" : "Luxembourg",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "Luxembourg",
"short_name" : "LU",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "Contern, Luxembourg",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 49.621830,
"lng" : 6.302790
},
"southwest" : {
"lat" : 49.56759010,
"lng" : 6.195380
}
},
"location" : {
"lat" : 49.58515930,
"lng" : 6.2274880
},
그리고 난 위치에서 위도와 LNG를 추출 할 :
내 JSON은 다음과 같습니다. 내 코드는 다음과 같습니다
arr = json.getJSONArray("results");
JSONObject location=arr.getJSONObject(4);
double lng = location.getDouble("lng");
double lat = location.getDouble("lat");
그리고 지금 당신은 무엇을 기대합니까? – RvdK
전체 json 문자열을 게시하십시오. –