
Untitled
By: a guest on
May 1st, 2012 | syntax:
None | size: 0.99 KB | hits: 12 | expires: Never
JSON parsing with javascript
{
"status": {
"http_code": 200
},
"contents": "HTTP/1.1 200 OKrnTransfer-Encoding: chunkedrnDate: Tue, 07 Feb 2012 08:14:38 GMTrnServer: localhostrnrn {"response": "true"} "
}
success: function(data) {
var objstring = JSON.stringify(data);
var result = jQuery.parseJSON(JSON.stringify(data));
alert(objstring);
var result1 = jQuery.parseJSON(JSON.stringify(result.contents[0]));
alert(result1.response);
alert(data.contents[0].response);
data = jQuery.parseJSON(theAboveMentionedJsonAsString);
var contentBody = data.contents.split("rnrn", 2)[1];
var response = jQuery.parseJSON(contentBody).response;
// "true"
dataType: 'json',
success: function(data) {
alert(data.status.http_code);
alert(data.contents);
}
var objstring=JSON.stringify(data);
var result=JSON.parse(objstring);
alert("http code:" + result.status.http_code);
alert("contents:" + result.contents);