What I meant is that GSON do not wrap the response as follows:

{
 "responseHeader":{
  "status":0,
  "QTime":x},
 "response":{"numFound":x,"start":0,"docs":[
        {
           /* docs */
        }]
 },
 "facet_counts":{
  "facet_queries":{},
  "facet_fields":{},
  "facet_dates":{}}}

If you care to preserve this format/pattern/whatever, you would need
to insert the JSON produced by GSON into such a body, and generate the
other attributes yourself.

That might not be needed, nor difficult to implement. BUT it's not
done out-of-the-box :)

For the application I'm developing I have a similar concern. I want to
do some authorizing and removing/adding content on the docs before I
send them off to the user. As I've already invested a lot of time
developing client-side code I want to preserve the exact same JSON
format.

Mats Bolstad



On Thu, Jul 29, 2010 at 12:40 PM, Mitch Köhler <mitc...@web.de> wrote:
> Hi Mat,
>
> sounds very interesting, because it seems to be so easy.
> You say, that this could comply with Solr's JSON-format.
> What are your experiences regarding the differences? I mean, JSON is a
> standard,
> so what can be different?
>
> Thank you!
> - Mitch
>
> Am 29.07.2010 09:42, schrieb Mats Bolstad:
>>
>> If you don't mind your JSON format complying with the one Solr uses,
>> you could use GSON.
>>
>> SolrQuery solrQuery = new SolrQuery("your query");
>> QueryResponse response = server.query(solrQuery);
>> List beans = response.getBeans(YourObject.class);
>> // some computing ...
>> GSON gson = new GSON();
>> String json = gson.toJSON(beans);
>>
>> Mats Bolstad
>>
>>
>> On Wed, Jul 28, 2010 at 1:54 PM, MitchK<mitc...@web.de>  wrote:
>>
>>>
>>> Hello community,
>>>
>>> I need to transform SolrJ - responses into JSON, after some computing on
>>> those results by another application has finished.
>>>
>>> I can not do those computations on the Solr - side.
>>>
>>> So, I really have to translate SolrJ's output into JSON.
>>>
>>> Any experiences how to do so without writing your own JSON-writer?
>>>
>>> Thank you.
>>> - Mitch
>>> --
>>> View this message in context:
>>> http://lucene.472066.n3.nabble.com/SolrJ-Response-JSON-tp1002024p1002024.html
>>> Sent from the Solr - User mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>
>

Reply via email to