Parsing json with android

后端 未结 4 2025
日久生厌
日久生厌 2021-01-28 09:44

Hi I want to parse this json:

[{
    \"codError\": 0,
    \"msg\": \"OK\"
}, {
    \"id\": 1,
    \"role\": {
        \"id\": 4,
        \"name\": \"Super\",
            


        
4条回答
  •  离开以前
    2021-01-28 10:05

    { represents the Jsonobject and [ represents the jsonarray

    Parse like this to get the role_id loginName from your json

     JSONArray jsonarr =new  JSONArray(yourstring);
     JSONObject jobj=jsonarr.getJSONObject(1);
     JSONObject role =jobj.getJSONObject("role");
     String role_id = role.getInt("id");
     String loginName=jsonarr.getString("loginName");
    

提交回复
热议问题