如何在java中从SolrDocumentList创建json类型的文档
我在这里得到了json响应,现在我想将此响应作为文档返回。那么我如何创建json文档呢?在方法(getPhotoGalleryDisplay(null).asXML())中,我正在从solr获取数据。能否请您指定如何在java中从SolrDocumentList创建json类型的文档,java,json,solr,Java,Json,Solr,我在这里得到了json响应,现在我想将此响应作为文档返回。那么我如何创建json文档呢?在方法(getPhotoGalleryDisplay(null).asXML())中,我正在从solr获取数据。能否请您指定文档和JSONObject类的完全限定名?那些是org.dom4j.Document(来自dom4j库)和org.json.JSONObject(来自Android库)吗?另外,getPhotoGalleryDisplay(…)的签名也将受到高度赞赏,是那些org.dom4j.Docum
文档
和JSONObject
类的完全限定名?那些是org.dom4j.Document
(来自dom4j库)和org.json.JSONObject
(来自Android库)吗?另外,getPhotoGalleryDisplay(…)
的签名也将受到高度赞赏,是那些org.dom4j.Document(来自dom4j库)和org.json.JSONObject(来自安卓库)。。。对不起,你什么意思?:-)对不起,实际上整个评论没有提交。org.dom4j.Document(来自dom4j库)和org.json.JSONObject(来自Android库)。。对Signature=public Document getPhotoGalleryDisplay(final RequestContext上下文),在这个方法中,我编写了从solr获取数据并生成xml文档的逻辑。实际上,我想用json文档代替SolrDocumentList中的xml文档。希望现在你能找到我。等待一个示例。好的,我的困惑来了:从一方面来说,您有public org.dom4j.Document getPhotoGallery(RequestContext context){…}
。从另一个角度看,您有public org.dom4j.Document convertDoctoJson(){…}
。它们都返回相同类型的返回,即org.dom4j.Document
,这是对XML文档的抽象。我的具体问题是:JSON从何而来?您实际上在寻找从org.dom4j.Document
到org.json.JSONObject
的转换,这是正确的假设吗?
public Document convertDoctoJson() throws JSONException
{
JSONObject jsd= org.json.XML.toJSONObject(getPhotoGalleryDisplay(null).asXML());
...
here will be code to create json document
...
return jsd;
}