var text = "문자열";
if (/^[\],:{}\s]*$/.test(text.replace(/\\["\\\/bfnrtu]/g, '@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
console.log("is jsonString");
//the json is ok
}else{
console.log("is not jsonString");
//the json is not ok
}
끝
댓글 없음:
댓글 쓰기