Get Key and values from JSONObject

前端 未结 3 1106
半阙折子戏
半阙折子戏 2020-12-18 02:30

I am trying to extract Key and values from my JSONObject. But i am not able to do that. Here is the JSON:

[{\"id\":[\"5\"]},{\"Tech\":[\"Java\"]}]

3条回答
  •  無奈伤痛
    2020-12-18 02:57

    Because at id you dont have a string , you have a array of string ,

    so insted of doing this jsonObj.getString("id");

    do this

    jsonObj.getArray("id"); this will give you that array in return

    like if you have a Json Array at id then you have to do this

    jsonObj.getJSONArray("id");

提交回复
热议问题