Json解析之JsonArray String str = "{\"phone\" : [\"12345678\", \"87654321\"]}";
try {
//注意List是实现Collection接口的
String str = "{\"phone\" : [\"12345678\", \"87654321\"]}";
JSONObject json = new JSONObject(str);
JSONArray array = json.getJSONArray("phone");
StringBuffer sb = new StringBuffer();
for (int i = 0; i < array.length(); i++) {
String s = (String) array.get(i);
sb.append(s+"\n");
}
textView.setText(sb.toString());
} catch (JSONException e) {
e.printStackTrace();
}
时间: 2024-10-11 22:31:35