判断JSon是否为空

来源:互联网 发布:手机上录歌的软件 编辑:程序博客网 时间:2024/05/18 02:53




  function JsonIsNull(value) {            var type;            if (value == null) { // 等同于 value === undefined || value === null                return true;            }            type = Object.prototype.toString.call(value).slice(8, -1);            switch (type) {                case 'String':                    return !!$.trim(value);                case 'Array':                    return !value.length;                case 'Object':                    return $.isEmptyObject(value); // 普通对象使用 for...in 判断,有 key 即为 false                default:                    return false; // 其他对象均视作非空            }        };

原文:http://lync.in/check-empty-value-in-javascript/

原创粉丝点击