用js构建json字符串

            //创建json对象
            var json = {};
            json.orderId = "${pd.orderId }";
            
            //提取包裹参数构建数组并且放入json中
            var rows = $('#dataGrid').bootstrapTable('getData');
            var details = [];
            for (var i = 0; i < rows.length; i++) {
                var row = {};
                row.expressCompany = rows[i].expressCompany;
                row.expressNo = rows[i].expressNo;
                row.deliverName = rows[i].deliverName;
                row.deliverPhone = rows[i].deliverPhone;
                row.goodsIds = rows[i].goodsIds;
                details.push(row);
            }
            json.details = details;
            $("#json").val(JSON.stringify(json));

你可能感兴趣的:(用js构建json字符串)