JavaCloudant-为什么find方法不返回JSON而不是输入流?

JavaCloudant-为什么find方法不返回JSON而不是输入流?,java,json,couchdb,cloudant,Java,Json,Couchdb,Cloudant,我正在尝试从cloudant获取文档,在获取文档后,它无法转换为它在模型类中包含的接口嵌套对象 Service service = getDB().find(Service.class, service.get_id()); 在我的例子中,服务类有多个接口作为成员变量,我不能在从cloudant获取文档时强制转换它 有没有更好的方法来取? 或者cloudant库是否可以提供返回类型为JSONString的方法(它们接受json作为参数的方式?您可以使用JSONObject代替服务类。添加以下m

我正在尝试从cloudant获取文档,在获取文档后,它无法转换为它在模型类中包含的接口嵌套对象

Service service = getDB().find(Service.class, service.get_id());
在我的例子中,服务类有多个接口作为成员变量,我不能在从cloudant获取文档时强制转换它

有没有更好的方法来取?
或者cloudant库是否可以提供返回类型为JSONString的方法(它们接受json作为参数的方式?

您可以使用JSONObject代替服务类。添加以下maven依赖项:

<dependency>
   <groupId>org.apache.wink</groupId>
   <artifactId>wink-json4j</artifactId>
   <version>1.4</version>
</dependency>
将文档作为JSONObject从数据库中获取:

JSONObject service = getDB().find(JSONObject.class, service.get_id());
仅供参考,我相信谷歌Gson的JSONObject也会起作用:

<dependency>
   <groupId>com.google.code.gson</groupId>
   <artifactId>gson</artifactId>
   <version>2.7</version>
</dependency>

com.google.code.gson
格森
2.7

您可以使用JSONObject代替服务类。添加以下maven依赖项:

<dependency>
   <groupId>org.apache.wink</groupId>
   <artifactId>wink-json4j</artifactId>
   <version>1.4</version>
</dependency>
将文档作为JSONObject从数据库中获取:

JSONObject service = getDB().find(JSONObject.class, service.get_id());
仅供参考,我相信谷歌Gson的JSONObject也会起作用:

<dependency>
   <groupId>com.google.code.gson</groupId>
   <artifactId>gson</artifactId>
   <version>2.7</version>
</dependency>

com.google.code.gson
格森
2.7

从来没有这样想过!谢谢:)我从来没有这样想过!谢谢:)