Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove double quotes from Json return data using Jquery

I use JQuery to get Json data, but the data it display has double quotes. It there a function to remove it?

$('div#ListingData').text(JSON.stringify(data.data.items[0].links[1].caption)) 

it returns:

"House" 

How can I remove the double quote? Cheers.

like image 732
Alex Avatar asked May 16 '13 22:05

Alex


2 Answers

Use replace:

var test = "\"House\""; console.log(test); console.log(test.replace(/\"/g, ""));    // "House" // House 

Note the g on the end means "global" (replace all).

like image 57
McGarnagle Avatar answered Oct 06 '22 00:10

McGarnagle


For niche needs when you know your data like your example ... this works :

JSON.parse(this_is_double_quoted);  JSON.parse("House");  // for example 
like image 27
Scott Stensland Avatar answered Oct 06 '22 01:10

Scott Stensland