在jQuery中 关于json空对象筛选替换

2020-05-22 22:01:14易采站长站整理

                }
            });
            return obj;
        }
        validateArray2 = function(obj, key, excluded){
            for(var i = 0, length = obj[key].length; i < length; i++){
                $.each(obj[key][i] ,function(subKey, subValue){
                    if(isInvalid(subKey, subValue, excluded)){
                        obj[key][i][subKey] = “N/A”;
                    }
                });
            }
            return obj;
        }
        isInvalid = function(key, value, excluded){
            return (($.inArray(key, excluded) == -1) && ($.isBlank(value))) ? true : false;
        }
        $.isBlank = function(obj){
            return(!obj || $.trim(obj) === “”);
        };

Method 1 结果


 


Method 2 结果