blob: 0b3d39833aab8b5340ac51d439c867683d555281 [file]
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export function ignoreNull(obj) {
let _newPar = {};
for (let key in obj) {
//如果对象属性的值不为空,就保存该属性(这里我做了限制,如果属性的值为0,保存该属性。如果属性的值全部是空格,属于为空。)
if ((obj[key] === 0 || obj[key]) && obj[key].toString().replace(/(^\s*)|(\s*$)/g, '') !== '') { // NOSONAR
//记录属性
_newPar[key] = obj[key];
}
}
//返回对象
return _newPar;
}