function isJSON(str) {
try {
JSON.parse(str)
}
catch {
return false
}
return true
}
var str = "JavaScript"
console.log(isJSON(str))
string json or not
Check is the string is JSON or not in JavaScript
0 Comments
Add Comment
Log in to add a comment