I want to add a JSONObject to a JSONArray and that JSONArray included in other JSONObject

前端 未结 4 832
梦谈多话
梦谈多话 2020-12-16 14:27

I need below kind of structure constructed in java and send it as response :

var abc = {
  "action": "         


        
4条回答
  •  北海茫月
    2020-12-16 15:13

    org.json.simple.JSONArray resultantJson = new org.json.simple.JSONArray();
    
            org.json.JSONArray o1 = new org.json.JSONArray("[{\"one\":[],\"two\":\"abc\"}]");
            org.json.JSONArray o2 = new org.json.JSONArray("[{\"three\":[1,2],\"four\":\"def\"}]");
    
    
            resultantJson.addAll(o1.toList());
            resultantJson.addAll(o2.toList());
    

提交回复
热议问题