We are using the Google Gson project to handle converting our objects / maps to 
json.  I will have to take a look at the plugin, I was not even aware of its 
existence.  

http://code.google.com/p/google-gson/

We put the result from Gson into an InputStream and send it back out using the 
stream result

                <result name="success" type="stream">
                         <param name="contentType">application/json</param>
                         <param name="inputName">jsonStream</param>
                         <param name="bufferSize">1024</param>
                </result>

Here is the line from our action that is setting up the InputStream from Gson.

setJsonStream(new ByteArrayInputStream(new 
Gson().toJson(jsonResult).getBytes()));


jsonResult is a Map, but could be any object or list of Objects.

Paul 


-----Original Message-----
From: Harsh C [mailto:hchau...@gmail.com] 
Sent: Wednesday, March 09, 2011 7:24 AM
To: Struts Users Mailing List
Subject: Re: Struts 2.0.11.1 question

Thanks for the responses all. "Not blessed" just means that it is not in the
list of s/w that we are allowed to work with.

I ended up writing just a plain servlet for now to serve the JSON string
which works well enough, except the JSON parsing part of course.

HC


On Mar 9, 2011 1:19 AM, "Maurizio Cucchiara" <maurizio.cucchi...@gmail.com>
wrote:
> What do you mean by "not blessed"?
>
> Maurizio Cucchiara
>
> Il giorno 09/mar/2011 00.24, "Harsh C" <hchau...@gmail.com> ha scritto:
> Hi,
>
> I don't know if this is the right list for a question regarding 2.0.11.1,
if
> not please let me know the right forum.
>
> I am trying to use Struts 2.0.11.1 to work on an AJAX-ified app using
Dojo.
> Problem is, struts-json plugin is not blessed.
>
> Is there a way in which I can code an Action which returns a JSON string
> without using the JSON plugin?
>
> --
> *Thanks,
> Harsh*

The information contained in this transmission contains confidential  
information that is legally privileged. This information is intended only for 
the use of the individual or entity named above. The authorized recipient of 
this information is prohibited from disclosing this information to any other 
party unless required to do so by law or regulation and is required to destroy 
the information after its stated need has been fulfilled.
If you are not the intended recipient, you are hereby notified that any 
disclosure, copying, distribution, or action taken in reliance on the contents 
of these documents is strictly prohibited. If you have received this 
information in error, please notify the sender immediately by return email and 
arrange for the return or destruction of these documents.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to