简体   繁体   中英

Java JSON-Lib Set Field only one entry

I am having a correct JSON String which is made out of an Object A, containing a Set of other Objects B.

When I try to get back this Object now from the JSON String, the Set of Objects B will only have a single entry, instead of all the contained in the JSON String.

Any suggestions, or did I just do something forbidden??

Thanks

For those who might fall over it, this solved the problem with the Set:

JSONArray jsonArray = JSONArray.fromObject(object);
JSONObject jsonObject = new JSONObject();
jsonObject.put("data", jsonArray.toString());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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