How to convert JSONObjects to JSONArray?

后端 未结 4 1778
伪装坚强ぢ
伪装坚强ぢ 2020-11-28 12:12

I have a response like this:

{
 \"songs\":{
          \"2562862600\":{\"id\":\"2562862600\"\"pos\":1},
          \"2562862620\":{\"id\":\"2562862620\"\"pos\"         


        
4条回答
  •  遥遥无期
    2020-11-28 12:35

    Even shorter and with json-functions:

    JSONObject songsObject = json.getJSONObject("songs");
    JSONArray songsArray = songsObject.toJSONArray(songsObject.names());
    

提交回复
热议问题