json 배열에서 JSON 객체를 얻는 방법을 알고 있습니까?json 배열에서 객체 가져 오기
JSON :
[
{
"id": 1,
"region": "Ilocos Region (Region I)",
"province": "Ilocos Norte",
"city": "Laoag City"
},
{
"id": 2,
"region": "Ilocos Region (Region I)",
"province": "Ilocos Norte",
"city": "Batac City"
},
{
"id": 3,
"region": "Ilocos Region (Region I)",
"province": "Ilocos Sur",
"city": "Vigan City"
}
]
나는 지역, 지방 및 도시를 얻을 수 있지만 내가 ID를 얻을 수 없습니다. 이 같은 방법으로 얻을 수없는,
try {
br = new BufferedReader(new FileReader(path+"json/src_city.json"));
try {
while ((inputline = br.readLine()) != null) {
JSONArray a = (JSONArray) parser.parse(inputline);
for (Object o : a) {
JSONObject sample = (JSONObject) o;
id = (int) sample.get("id");
}}
나는 내 질문에 대한 답을 찾았으며 잘 설명했다. http://stackoverflow.com/a/31194430/1840521 – LyodMichael