jq form values converted into json string form

Since the background is defined interfaces, you must change the form submitted content into json string, so write a value converted to the form in the form of a string json function.

Under the prerequisite should be introduced distal JQuery, refer to the following:

  /** 表单序列化成json字符串的方法  */

        function form2JsonString(formId) {

            var paramArray = $('#' + formId).serializeArray();  

             /*请求参数转json对象*/  

             var jsonObj={};  

              $(paramArray).each(function(){  

                  jsonObj[this.name]=this.value;  

              });  
          
             // json对象再转换成json字符串

             return JSON.stringify(jsonObj);
        }

Second, the use of

Third, resolve backstage

proApprovalStage = JSON.parseObject(JSON.parse(jsonStr).toString(),ProApprovalStage.class);
Published 100 original articles · won praise 47 · views 210 000 +

Guess you like

Origin blog.csdn.net/sl1990129/article/details/102854698