json.js 中 json对象的扩展 增加的对 struts2的支持

if (!this.JSON) {
    JSON = {};
}
(function () {
     //增加的对 struts2的支持
     postArgument = "";   //post argument  global  
     function str2(key, holder){
            var i,          // The loop counter.

            k,          // The member key.

            v,          // The member value.         

            value = holder[key];
            if(key!=""){
            postArgument = postArgument + key +"="+ value + "&"; 
            }                    
            if (!value) {

                return 'null';

            }

            for (k in value) {

                  if (Object.hasOwnProperty.call(value, k)) {

                      str2(k, value);
                    }
            }                              
     }
     if (typeof JSON.struts2 !== 'function') {
            JSON.struts2 = function (value) {
                postArgument = "";//clean postArgument here case save postArg  can hold several record and update
                str2('', {'': value});
                return  postArgument.substr(0,postArgument.length-1);
                }
       }

 

你可能感兴趣的:(json)