js的:原文地址https://www.cnblogs.com/lanleiming/p/7096973.html
function isJSON(str) {
if (typeof str == 'string') {
try {
var obj=JSON.parse(str);
if(typeof obj == 'object' && obj ){
return true;
}else{
return false;
}
} catch(e) {
console.log('error:'+str+'!!!'+e);
return false;
}
}
console.log('It is not a string!')
}
java的:
还没找到合适的!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
本文提供了一个JavaScript函数,用于检查字符串是否为有效的JSON格式。通过尝试将字符串解析为JSON对象并验证其类型,此函数能够帮助开发者确保数据符合JSON标准。
8107

被折叠的 条评论
为什么被折叠?



