Android JSON parsing of multiple JSONObjects inside JSONObject

后端 未结 6 1589
面向向阳花
面向向阳花 2020-11-29 10:28

I have a JSON string coming from the server and it looks like this:

{
    \"categories\": {
        \"0\": {
            \"term_id\": \"247\",
            \"         


        
6条回答
  •  既然无缘
    2020-11-29 11:15

    try this

    JSONObject jObject = new JSONObject(responceData);
    JSONObject categoryObject = jObject.getJSONObject("categories");
    JSONObject obj0 = categoryObject.getJSONObject("0");
    String termId0 obj0.getString("term_id");
    String name0 obj0.getString("name");
    JSONObject obj1 = categoryObject.getJSONObject("1");
    String termId1 obj1.getString("term_id");
    String name1 obj1.getString("name");
    

    but i agree with wqrahd, categories should be an array

提交回复
热议问题