最近我一直試圖解析在android工作室使用凌空框架json。當我在閱讀的教程中使用代碼時,一切正常。但是,當我嘗試解析我自己的json時,某些內容不起作用。具體JSON不會解析android工作室使用凌亂
這是我的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網址: http://portaal-gem-lwd.opendata.arcgis.com/datasets/1f505f23ef0a4f92aa32b0c8b98e8cbf_0.geojson
的問題是,它根本不給輸出。
在此先感謝
PS。這是我讀的教程的網址https://www.thorntech.com/2016/03/parsing-json-android-using-volley-library/
我試圖鏈接到您的JSON以下到TextView的,但是我最終下載,我是在我的電腦真的不舒服打開一個文件。所以,我無法檢查JSON的有效性。嘗試使用[json lint](https://jsonlint.com)等網站來檢查JSON的有效性。同時查看您的日誌數據或異常/錯誤(如果有的話)。如果它們存在,你應該發佈這些。 –