You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by sharath karnati <ka...@yahoo.com> on 2008/08/04 16:25:16 UTC
Struts2 with JSON.
Hi All,
Using JSON, I'm getting below response from action
{"list":{"com.beans.ComplaintDO":{"user__complaint__number":"08-C00000153","user__complaint__key":"08-C00000153-1","form__type":"2000B","first__name":"Sharath","last__name":"Karnati"}}}
In this response, 'com.beans.ComplaintDO' is a javabean. 'list' is a java arraylist and it may contain multiple 'com.beans.ComplaintDO' javabeans.
I'd like to know how to read this response in java script, I tried below way but getting java script error(jsonObject has no properties)
function onReadyState()
{
alert('In onReadyState');
var ready=req.readyState;
var jsonObject=null;
if ( ready == READY_STATE_COMPLETE )
{
jsonObject=eval( req.responseText );
var searchresults = jsonObject.ComplaintDO.entry;
alert('In searchresults:'+searchresults.length);
}
}
Please let me know how to read these values from json object.
Thanks,
Sharath.
Re: Struts2 with JSON.
Posted by Musachy Barroso <mu...@gmail.com>.
jsonObject.list["com.beans.ComplaintDO"]["first__name"]
Not related to struts in anyway btw.
musachy
On Tue, Aug 5, 2008 at 5:09 PM, sharath karnati <ka...@yahoo.com> wrote:
> Hi All,
>
> I'm getting below value in req.responseText
>
> {"list":{"com.beans.ComplaintDO":{"first__name":"Sharath","last__name":"Karnati"}}}
>
> which I'm passing for JSON
>
> jsonObject=eval( "("+ req.responseText +")" );
>
> How to read 'first__name' value from jsonObject?
>
> Thanks,
> Sharath.
>
> --- On Mon, 8/4/08, sharath karnati <ka...@yahoo.com> wrote:
>
> From: sharath karnati <ka...@yahoo.com>
> Subject: Struts2 with JSON.
> To: user@struts.apache.org
> Date: Monday, August 4, 2008, 10:25 AM
>
> Hi All,
>
> Using JSON, I'm getting below response from action
>
>
> {"list":{"com.beans.ComplaintDO":{"user__complaint__number":"08-C00000153","user__complaint__key":"08-C00000153-1","form__type":"2000B","first__name":"Sharath","last__name":"Karnati"}}}
>
> In this response, 'com.beans.ComplaintDO' is a javabean.
> 'list' is a java arraylist and it may contain multiple
> 'com.beans.ComplaintDO' javabeans.
>
> I'd like to know how to read this response in java script, I tried below
> way but getting java script error(jsonObject has no properties)
>
> function onReadyState()
> {
> alert('In onReadyState');
> var ready=req.readyState;
> var jsonObject=null;
>
> if ( ready == READY_STATE_COMPLETE )
> {
> jsonObject=eval( req.responseText );
> var searchresults = jsonObject.ComplaintDO.entry;
> alert('In searchresults:'+searchresults.length);
> }
> }
>
> Please let me know how to read these values from json object.
>
> Thanks,
> Sharath.
>
>
>
>
>
>
>
>
>
--
"Hey you! Would you help me to carry the stone?" Pink Floyd
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Struts2 with JSON.
Posted by sharath karnati <ka...@yahoo.com>.
Hi All,
I'm getting below value in req.responseText
{"list":{"com.beans.ComplaintDO":{"first__name":"Sharath","last__name":"Karnati"}}}
which I'm passing for JSON
jsonObject=eval( "("+ req.responseText +")" );
How to read 'first__name' value from jsonObject?
Thanks,
Sharath.
--- On Mon, 8/4/08, sharath karnati <ka...@yahoo.com> wrote:
From: sharath karnati <ka...@yahoo.com>
Subject: Struts2 with JSON.
To: user@struts.apache.org
Date: Monday, August 4, 2008, 10:25 AM
Hi All,
Using JSON, I'm getting below response from action
{"list":{"com.beans.ComplaintDO":{"user__complaint__number":"08-C00000153","user__complaint__key":"08-C00000153-1","form__type":"2000B","first__name":"Sharath","last__name":"Karnati"}}}
In this response, 'com.beans.ComplaintDO' is a javabean.
'list' is a java arraylist and it may contain multiple
'com.beans.ComplaintDO' javabeans.
I'd like to know how to read this response in java script, I tried below
way but getting java script error(jsonObject has no properties)
function onReadyState()
{
alert('In onReadyState');
var ready=req.readyState;
var jsonObject=null;
if ( ready == READY_STATE_COMPLETE )
{
jsonObject=eval( req.responseText );
var searchresults = jsonObject.ComplaintDO.entry;
alert('In searchresults:'+searchresults.length);
}
}
Please let me know how to read these values from json object.
Thanks,
Sharath.