Ich bin JSON Zeichenfolge in URL analysieren.Android String zu JSON Array Fehler
TextView tv3 = (TextView) findViewById(R.id.tv3);
TextView tv2 = (TextView) findViewById(R.id.tv2);
TextView tv1 = (TextView) findViewById(R.id.tv1);
String str = "[{\"ID\":\"1\",\"lat\":\"40.7646815\",\"lon\":\"29.030855\"},{\"ID\":\"2\",\"lat\":\"41.10812\",\"lon\":\"29.030855\"}]";
JSONArray jsonarray = null;
try {
jsonarray = new JSONArray(str);
for (int i = 0; i < jsonarray.length(); i++) {
JSONObject obj = jsonarray.getJSONObject(i);
String lat = obj.getString("lat");
String lon = obj.getString("lon");
String id = obj.getString("ID");
tv3.setText(lat);
tv2.setText(lon);
tv1.setText(ID);
}
} catch (JSONException e) {
e.printStackTrace();
}
Ich möchte Umwandlung JSONArray
-String
aber JSONArray Rückkehr leer. Wo bin ich Fehler? Danke ..
@prudhvi wissen Sie nicht, wie zitiert in Java-Strings zu entkommen? – njzk2
irgendeine Ausnahme überhaupt? – njzk2