I have variable for example
var x = "this is X value";
How to check in node.js if variable is JSON object ?
Your question is not clear, but assuming you meant to check if a variable has an unparsed JSON string:
try {
JSON.parse(x);
} catch (e) {
console.log("not JSON");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With