Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在java中从SolrDocumentList创建json类型的文档_Java_Json_Solr - Fatal编程技术网

如何在java中从SolrDocumentList创建json类型的文档

如何在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

我在这里得到了json响应,现在我想将此响应作为文档返回。那么我如何创建json文档呢?在方法(getPhotoGalleryDisplay(null).asXML())中,我正在从solr获取数据。

能否请您指定
文档
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;

 }