假设我从一个服务请求中得到一些JSON,如下所示:
{
"message": "We're unable to complete your request at this time."
}
我不确定为什么这个apostraphe是这样编码的('
);我只知道我想解码它。
下面是我脑海中突然出现的一种使用jQuery的方法:
function decodeHtml(html) {
return $('<div>').html(html).text();
}
不过,这看起来(非常)有些老生常谈。有什么更好的方法吗?有没有“正确”的方法?
https://stackoverflow.com/questions/7394748
复制相似问题