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

前端 未结 4 834
梦谈多话
梦谈多话 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:05

    JSONObject json = new JSONObject();
    json.put("fromZIPCode","123456"); 
    
    JSONObject json1 = new JSONObject();
    json1.put("fromZIPCode","123456"); 
           sList.add(json1);
           sList.add(json);
    
    System.out.println(sList);
    
    Output will be
    
    [{"fromZIPCode":"123456"},{"fromZIPCode":"123456"}]
    

提交回复
热议问题