解析JSONArray

前端之家收集整理的这篇文章主要介绍了解析JSONArray前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
//[{"k":"20","na":"30"},{"k":"50","na":"60"},{"k":"10","na":"40"},{"k":"30","na":"80"}] String json = this.getResources().getString(R.string.json); try { JSONArray array = new JSONArray(json); int[] n = new int[array.length()]; for (int i = 0; i < array.length(); i++) { JSONObject jsonObject = array.getJSONObject(i); n[i] = jsonObject.getInt("k"); Log.i("ceshi",n[i] + ""); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } 原文链接:https://www.f2er.com/json/290622.html

猜你在找的Json相关文章