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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *