Jsonオブジェクトは同じkeyでvalue値を統合します.

1933 ワード

 var s = '{"  ":"175cm","  ":" ","  ":"  ","  ":"  ","  ":"  "}'
    var kv = {}, m, reg = /"[^"]+":"[^"]+"/gi;
    var m = s.match(reg);

    var o={};
    for(var i=0;imatch(/"[^"]+"/gi);
         var _arr1=[];;
        for(var j=0;j/g,''));
        }
        if(_arr1[0] in o){
            if(typeof(o[_arr1[0]])=='string')
            {
                o[_arr1[0]]=[o[_arr1[0]]]
            };
            o[_arr1[0]].push(_arr1[1])
        }else{
            o[_arr1[0]]=_arr1[1]
        }

    }
    console.log(o)//'{"  ":"175cm","  ":" ","  ":["  ,"  ","  "]}'