- function dealNull(obj){
- for(var i in obj){
- if(null == obj[i] || 'null' == obj[i]){
- obj[i]='';
- }else if('object' == typeof obj[i]){
- dealNull(obj[i]);
- }
- }
- };
- // 测试的对象
- var a={};
- a.aa=null;
- a.bb='null';
- a.c=1;
- a.b={};
- a.b.aaa=null;
- a.b.bbb='null';
- a.b.c=1;
- a.array=[];
- a.array.push({'a':null,'b':'null','c':1});
- a.array.push({'a1':null,'b1':'null','c1':1});
- a.array.push({'a2':null,'b2':'null','c2':1});
- dealNull(a);
- //该片段来自于http://www.codesnippet.cn/detail/2210201410781.html
来源: http://www.codesnippet.cn/detail/2210201410781.html