如何使用String创建JSON对象?

如何使用String创建JSON对象?,第1张

如何使用String创建JSON对象

JSONArray
可能就是您想要的。

String message;JSonObject json = new JSonObject();json.put("name", "student");JSonArray array = new JSonArray();JSonObject item = new JSonObject();item.put("information", "test");item.put("id", 3);item.put("name", "course1");array.add(item);json.put("course", array);message = json.toString();// message// {"course":[{"id":3,"information":"test","name":"course1"}],"name":"student"}


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5642588.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-16
下一篇2022-12-16

发表评论

登录后才能评论

评论列表(0条)

    保存