简体   繁体   English

如何将json对象传递给json数组

[英]How to pass json object into json array

I am new to J2EE and JSON.我是 J2EE 和 JSON 的新手。 I am using jsonArray.put(jsonObject) for adding a json object to a json array but its showing error message:我正在使用jsonArray.put(jsonObject)将 json 对象添加到 json 数组,但它显示错误消息:

The method put(JSONObject) is undefined for the type JSONArray.未定义 JSONArray 类型的 put(JSONObject) 方法。

The library I am using for json is org.json.simple.*我用于 json 的库是org.json.simple.*

Please help me out.请帮帮我。

The method to put new stuff into an array is called add .将新内容放入数组的方法称为add So:所以:

jsonArray.add(jsonObject)

should work.应该管用。

Please refer to the documentation for details.有关详细信息,请参阅文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM