Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 0.99 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. JSON parsing with javascript
  2. {
  3. "status": {
  4.     "http_code": 200
  5. },
  6. "contents": "HTTP/1.1 200 OKrnTransfer-Encoding: chunkedrnDate: Tue, 07 Feb 2012 08:14:38 GMTrnServer: localhostrnrn {"response": "true"} "
  7. }
  8.        
  9. success: function(data) {
  10.             var objstring = JSON.stringify(data);
  11.             var result = jQuery.parseJSON(JSON.stringify(data));
  12.             alert(objstring);
  13.  
  14.             var result1 = jQuery.parseJSON(JSON.stringify(result.contents[0]));
  15.             alert(result1.response);
  16.  
  17.             alert(data.contents[0].response);
  18.        
  19. data = jQuery.parseJSON(theAboveMentionedJsonAsString);
  20.        
  21. var contentBody = data.contents.split("rnrn", 2)[1];
  22.        
  23. var response = jQuery.parseJSON(contentBody).response;
  24. // "true"
  25.        
  26. dataType: 'json',
  27. success: function(data) {
  28.     alert(data.status.http_code);
  29.     alert(data.contents);
  30. }
  31.        
  32. var objstring=JSON.stringify(data);
  33. var result=JSON.parse(objstring);
  34.  
  35. alert("http code:" + result.status.http_code);
  36. alert("contents:" + result.contents);