Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove double quotes from default string in javascript/Jquery

I have one string

"{'name':'xyz'}","{'name':'PQR'}"

I need to remove double quotes it should be

{'name':'xyz'},{'name':'PQR'}

I am able to remove double quotes but end result is always like below format

"{'name':'xyz'},{'name':'PQR'}"

i want end result should be just

{'name':'xyz'},{'name':'PQR'}

Ideas are helpful

like image 538
Ashwinik Avatar asked Feb 17 '15 07:02

Ashwinik


2 Answers

Using below code you can remove double quotes from a string:

var test = "\"House\"";
alert(test);
alert(test.replace(/\"/g, ""));
like image 77
Sunny Avatar answered Oct 19 '22 17:10

Sunny


It is solved by converting current object to string and then used eval function,Worked solved thanks.

var eventlist = JSON.stringify(eventresult.d);//Jsonresult

var eventstring = new String();

eventstring = eventlist.toString().replace(/"/g, "");

eval(eventstring );
like image 34
Ashwinik Avatar answered Oct 19 '22 17:10

Ashwinik