What is the best way to combine (merge) 2 JSONObjects?

后端 未结 5 1384
梦毁少年i
梦毁少年i 2021-02-19 02:14

What is the best way to combine (merge) two JSONObjects?

JSONObject o1 = {
    \"one\": \"1\",
    \"two\": \"2\",
    \"three\": \"3\"
}
JSONObject         


        
5条回答
  •  面向向阳花
    2021-02-19 02:55

    Try this.. hope it helps

    JSONObject result = new JSONObject();
    result.putAll(o1);
    result.putAll(O2);
    

提交回复
热议问题