There is a distinction between html encoding and URI encoding. HTML entities cannot be decoded using a built-in function, but this response offers a straightforward solution:
The provided code snippet from the aforementioned answer is included below:
function convertHTMLEntity(text){
const span = document.createElement('span');
return text
.replace(/&[#A-Za-z0-9]+;/gi, (entity,position,text)=> {
span.innerHTML = entity;
return span.innerText;
});
}
console.log(JSON.parse(convertHTMLEntity(your_encoded_json)));
It's important to note that this method relies on the DOM and therefore can only be executed in a browser environment.
If you're dealing with encoded double quotes and require a non-browser solution, you can utilize the following alternative:
console.log(JSON.parse(your_encoded_json.replace(/"/g, '"')));