通过数组或者列表生成json数组后添加到json对象中的方法

柔情只为你懂 2022-12-23 13:25 162阅读 0赞

把一个列表或数组生成json数组并添加到json对象中

  1. String string =JSON.toJSON(数组或者列表).toString();
  2. jsonArray =JSON.parseArray(string);
  3. jsonObject.put("添加的对象名",jsonArray);

手动向json数组中添加对象

  1. JSONObject json = new JSONObject();
  2. json.put("keya1", "heihei");
  3. jsonArray.add(json);//向Json数组对象中添加Json对象

发表评论

表情:
评论列表 (有 0 条评论,162人围观)

还没有评论,来说两句吧...

相关阅读