Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
例如,我有变量
var x = "this is X value";
如果变量是 JSON 对象,如何检查 node.js?
您的问题不清楚,但假设您要检查变量是否具有未解析的 JSON 字符串:
try { JSON.parse(x); } catch (e) { console.log("not JSON"); }