최근에 저는 발리 프레임 워크를 사용하여 android studio에서 json을 파싱하려고했습니다. 내가 읽은 튜토리얼에서 코드를 사용할 때, 모든 것이 잘 작동합니다. 그러나, 내 자신 json을 구문 분석하려고 할 때, 뭔가 작동하지 않습니다.특정 json은 발리를 사용하여 안드로이드 스튜디오를 구문 분석하지 않습니다
이 내 JSON 코드
JsonObjectRequest objectrequest = new JsonObjectRequest(hondenpoepURL, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
JSONObject type = response.getJSONObject("type");
JSONArray features = response.getJSONArray("features");
for (int i = 0; i < features.length(); i++) {
JSONObject bak = features.getJSONObject(i);
JSONObject geometry = bak.getJSONObject("geometry");
JSONArray coordinates = geometry.getJSONArray("coordinates");
double latitude = coordinates.getDouble(1);
double longitude = coordinates.getDouble(0);
data += "latitude: " + latitude + "\nlongitude: " + longitude +
"\n\n";
}
results.setText(data);
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e("Volley", "Error");
}
}
);
requestQueue.add(objectrequest);
이며,이 내 JSON의 URL입니다 : http://portaal-gem-lwd.opendata.arcgis.com/datasets/1f505f23ef0a4f92aa32b0c8b98e8cbf_0.geojson
문제는 단순히 출력을 제공하지 않는다는 것입니다.
미리 감사드립니다.
PS. 이 튜토리얼을 읽은 URL입니다. https://www.thorntech.com/2016/03/parsing-json-android-using-volley-library/
발리 응답 함수의 내부에서 텍스트 뷰 텍스트를 설정하기 위해 노력하고 있습니다,하지만 난 내 컴퓨터에서 정말로 편안 개방을 오전 파일을 다운로드 끝났다. 따라서 JSON의 유효성을 확인할 수 없었습니다. [json lint] (https://jsonlint.com)와 같은 웹 사이트를 사용하여 JSON의 유효성을 확인하십시오. 또한 로그 데이터 또는 예외/오류가 있는지 확인하십시오. 존재하는 경우 게시해야합니다. –