我非常幸运地使用 Google 的 JSON 库 (Gson) 将我的 Java 对象存储到 Memcached 中。我可以获取任何 Java 对象,使用 Gson 将其序列化,然后将其缓存在 Memcached 中。稍后我可以从 memcached 中获取 JSON 并将其反序列化为相同类型的对象。
我想为 couchdb 做一些非常相似的事情。 Couchdb 将文档存储为 Json,所以我想我可以找到一个具有存储和获取文档的 couchdb 客户端,如下所示:
couchdb.storeDocument("user12345", myAppUser);
MyAppUser user = couchdb.getDocument("user12345", MyAppUser.class);
最佳答案
埃克托普:http://ektorp.org/
基于 Jackson 但也提供原始访问: 在 org.ektorp.CouchDbConnector 中:
InputStream getAsStream(String s)
InputStream queryForStream(ViewQuery query);
也就是说,在大多数情况下,我看不出有什么好的理由不使用映射到对象的方法:
<T> T get(Class<T> c, String id);
关于java - 是否有使用 Gson 的 couchdb java 客户端?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9523659/