1.双引号替换成单引号 var domo = JSON.stringify(address).replace(/\"/g,"'"); var a = {a:1,b:2}; JSON.stringify(a)====>"{"a":1,"b":2}" 2.单引号替换成双引号 var value_name = value_name.replace(/'/g, '"'); 以下是Java后端要替换单引号为
在Firefox,chrome,opera,safari,ie9,ie8等浏览器直接可以用JSON对象的stringify()和parse()方法. 1.JSON.stringify(obj)将JS对象转为JSON字符串. //JS对象 var obj={"name":"tom","sex":"男","age":"24"}; //JS对象转化为JSON字符串 var jsonString
<script src="~/Content/Scripts/jquery-1.11.3.min.js"></script> <script> $(function () { var data = { GoThroughNo: "ABC00001", AwbList: [] }; for (var i = 0; i < 10; i++) { var hawbMapping = new Object(); hawbMappin