java - 两个 JSONObject 合并的问题
巴扎黑
巴扎黑 2017-04-17 17:49:38
0
1
335

最近使用 org.json.JSONObject 封装json数据,现在遇到想把两个 JSONObject 进行合并不知道怎么弄了,请教各位老司机指点一下。

import org.json.JSONObject;

JSONObject json1 = new JSONObject();
JSONObject json2 = new JSONObject();
        
json1.put("aa", 1111);
json1.put("bb", 2222);
        
json2.put("cc", 3333);
json2.put("dd", 4444);
        
System.out.println(json2);

想要得到json1与json2合并后的json格式,有没有相应的方法啊,我看了下API没找到。

{"aa":1111,"bb":2222,"cc":3333,"dd":4444}
巴扎黑
巴扎黑

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!