代码如下:
function isJSON(str) {
if (typeof str == 'string') {
try {
var obj=JSON.parse(str);
if(Object.prototype.toString.call(obj) == '[object Object]' && obj ){
return true;
}else{
return false;
}
} catch(e) {
console.log('error:'+str+'!!!'+e);
return false;
}
}
console.log('It is not a string!')
}
作者:雷明
来源:博客园
原文:https://www.cnblogs.com/lanleiming/p/7096973.html
版权声明:本文为博主原创文章,转载请附上博文链接!