var parm={ username:"zhangsan", age:24, email:"352400260@qq.com" }; console.log(JSON.stringify(parm)); var person = new Object(); person.username = "lisi"; person.age = "34"; person.email = "1350812980@qq.com"; console.log(JSON.stringify(person));
(function($){ $.fn.serializeJson=function(){ var serializeObj={}; var array=this.serializeArray(); $(array).each(function(){ if(serializeObj[this.name]){ if($.isArray(serializeObj[this.name])){ serializeObj[this.name].push(this.value); }else{ serializeObj[this.name]=[serializeObj[this.name],this.value]; } }else{ serializeObj[this.name]=this.value; } }); return serializeObj; }; })(jQuery);