Add JsonArray to JsonObject

前端 未结 5 1806
予麋鹿
予麋鹿 2020-11-27 20:52

I googled a lot today for this subject. But I can\'t find it, How can I add a JSONArray to a JSONObject?

Because everytime I do this I get this error: Stackoverflow<

5条回答
  •  情话喂你
    2020-11-27 21:26

    I'm starting to learn about this myself, being very new to android development and I found this video very helpful.

    https://www.youtube.com/watch?v=qcotbMLjlA4

    It specifically covers to to get JSONArray to JSONObject at 19:30 in the video.

    Code from the video for JSONArray to JSONObject:

    JSONArray queryArray = quoteJSONObject.names();
    
    ArrayList list = new ArrayList();
    
    for(int i = 0; i < queryArray.length(); i++){
        list.add(queryArray.getString(i));
    }
    
    for(String item : list){
        Log.v("JSON ARRAY ITEMS ", item);
    }
    

提交回复
热议问题