In my .js have a string
var jdata ="[{\"name\":\"John\"}]"
I want to convert it to [{“name”:”John”}].
I tried the following but fail
jdata = jdata.replace("\"","\"")
jdata = jdata.replace("\\"","\"")
jdata = jdata.replace("\\\"","\"")
What is the right way to replace?
If you want it to become an object just do this:
The result will be
[{"name":"John"}]objectified.Otherwise, you already have the job done. If you try to print
"[{\"name\":\"John\"}]"you will see that has no\character as it is an escape character.