struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sharath karnati <karna...@yahoo.com>
Subject Re: Struts2 with JSON.
Date Tue, 05 Aug 2008 21:09:03 GMT
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 <karnatis@yahoo.com> wrote:

From: sharath karnati <karnatis@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.
  
 
         


      


      
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message