如何使用Java创建JSON文档? [英] How to create a JSON document using Java?
本文介绍了如何使用Java创建JSON文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从数据库中读取数据,使用Java将其转换为docs(JSON)。
I want to read data from the database, convert it to docs (JSON) using Java.
谢谢
推荐答案
GSON 是Google的一个Java库,用于将Java对象转换为JSON。您只需将Java对象传递给库函数,它就会返回一个JSON字符串。
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.
下载: http://code.google.com/p/google-gson/
示例: http://www.mkyong.com/java/how-do-convert-java-object-to-from-json-format-gson-api/
我使用了 http://www.json.org上的库,但整件事对我来说似乎很乏味。 GSON很容易使用恕我直言。
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.
这篇关于如何使用Java创建JSON文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文