Sometimes, we want to remove ‘"’ from JSON in JavaScript.
In this article, we’ll look at how to remove ‘"’ from JSON in JavaScript.
How to remove ‘"’ from JSON in JavaScript?
To remove ‘"’ from JSON in JavaScript, we call the string replace
method.
For instance, we write
const obj = JSON.parse(data.replace(/"/g, '"'));
to call data.replace
with /"/g
and '"'
to replace all instances of '"'
with double quotes on the data
string.
Then we call JSON.parse
to parse the string returned by replace
into the obj
object.
Conclusion
To remove ‘"’ from JSON in JavaScript, we call the string replace
method.