try { String data = response.body().string(); if (null!=data){ JSONObject resultJson=new JSONObject(data); for (int j=0;j<resultJson.length();j++){ JSONArray listArray = resultJson.getJSONArray("list"); JSONObject jsonArray= listArray.getJSONObject(0); String stuid=jsonArray.getString("stuid"); if (stuNumber.equals(stuid)){ String stuName=jsonArray.getString("stuname"); Intent intent=new Intent(); intent.putExtra("stuid",stuid); intent.putExtra("stuname",stuName); intent.setClass(MainActivity.this,GetPictureActivity.class); startActivity(intent); finish(); } } } } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); }
data是object类型为list的父节点,list为array类型