Categories
JavaScript Answers

How to remove ‘&quot’ from JSON in JavaScript?

Spread the love

Sometimes, we want to remove ‘&quot’ from JSON in JavaScript.

In this article, we’ll look at how to remove ‘&quot’ from JSON in JavaScript.

How to remove ‘&quot’ from JSON in JavaScript?

To remove ‘&quot’ 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 '&quot' 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 ‘&quot’ from JSON in JavaScript, we call the string replace method.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.