公告
财富商城
积分规则
提问
发文
2020-07-23 04:19发布
Lonely孤独者°
I want to read data from the database, convert it to docs (JSON) using Java.
Thanks
GSON is a Java library from Google to convert Java objects to JSON. You can simply pass a Java object to the library function and it will return a JSON string.
Download: http://code.google.com/p/google-gson/
Example: http://www.mkyong.com/java/how-do-convert-java-object-to-from-json-format-gson-api/
I have used the library from http://www.json.org, but the whole thing seems to be tedious to me. GSON is simple to use IMHO.
I would use JSONObject class:
http://www.json.org/javadoc/org/json/JSONObject.html
or you can build the string.
最多设置5个标签!
GSON is a Java library from Google to convert Java objects to JSON. You can simply pass a Java object to the library function and it will return a JSON string.
Download: http://code.google.com/p/google-gson/
Example: http://www.mkyong.com/java/how-do-convert-java-object-to-from-json-format-gson-api/
I have used the library from http://www.json.org, but the whole thing seems to be tedious to me. GSON is simple to use IMHO.
I would use JSONObject class:
http://www.json.org/javadoc/org/json/JSONObject.html
or you can build the string.