maomingchao

判断是否是json

转:https://blog.csdn.net/dy_smile/article/details/46739251

function isJson(obj) {
var isjson = typeof (obj) == "object" && Object.prototype.toString.call(obj).toLowerCase() == "[object object]" && !obj.length;
return isjson;
}

 

node.js里面如果简单的用typeof,就会无法识别array和json.

posted on 2018-04-01 09:16  maomingchao  阅读(125)  评论(0)    收藏  举报

导航