json在发帖请求后破了

时间:2015-05-09 21:58:28

标签: javascript json angularjs node.js post

我正在尝试将json对象保存在数据库中。我使用帆作为后端,角度作为前端。

我在调用post请求之前有效JSON。

但是当我调用post请求时,json被破坏,只发送了一部分JSON。

这是我在角度服务中起诉的代码:

   GridService.saveTableConfig = function (key, data) {

      var test = JSON.parse(data); // Is correct no errors!

    return $http.post(config.serverUrl + "/admin/saveconfigtable/" + key +"/" + data);
  }

请在发布请求之前找到JSON的摘录:

  

" {"前缀":"""名称":"网格""列&# 34;:[{"编码":真,"标题":"线""字段":" ID&#34 ;,"可编辑":false,"可选":false,"模板":" div style = \" text-align:center \"> span class = \"徽章bg-cyan \" style = \" font-weight:bold; font-size:11px; \"> {{dataItem.id}} / span> / div>"," width&# 34;:100},{"编码":真,"标题":"状态""字段":"状态& #34;"可编辑的":假,"过滤":假,"宽度":100,"模板":" div style = \" text-align:center \"> span class = \" label \" ng-class = \" {' bg-danger':dataItem.businesserror!= null,' bg-greensea':dataItem.businesserror == null} \&#34 ; style = \" font-weight:bold; font-size:11px; \"> {{dataItem.status}} / span> / div>"},{"编码":真,"标题":"键""类型":"串""字段&#34 ;:" key"," editable":true," width":250," template":" span ng-bind =' dataItem.key'>#:data.key#/ span>"},{"编码":true,"标题":& #34; KEYEN""类型":"串""字段":" KEYEN""可编辑的&# 34;:真,"验证" {"需":真}"宽度" 250"模板":&#34 ; span ng-bind =' dataItem.keyen'>#:data.keyen#/ span>"},

当我发布JSON时,我只检索下面的完整JSON。部件丢失或被移除。它似乎是在#:

之后
  

" {"前缀":"""名称":"网格""列&# 34;:[{"编码":真,"标题":"线""字段":" ID&#34 ;,"可编辑":false,"可选":false,"模板":" div style = /" text-align:center /"> span class = /"徽章bg-cyan /" style = /" font-weight:bold; font-size:11px; /"> {{dataItem.id}} / span> / div>"," width&# 34;:100},{"编码":真,"标题":"状态""字段":"状态& #34;"可编辑的":假,"过滤":假,"宽度":100,"模板":" div style = /" text-align:center /"> span class = /" label /" ng-class = /" {' bg-danger':dataItem.businesserror!= null,' bg-greensea':dataItem.businesserror == null} /&#34 ; style = /" font-weight:bold; font-size:11px; /"> {{dataItem.status}} / span> / div>"},{"编码":真,"标题":"键""类型":"串""字段&#34 ;:" key"," editable":true," width":250," template":" span ng-bind =' dataItem.key'>"

有什么想法吗?

谢谢,

1 个答案:

答案 0 :(得分:0)

好的,谢谢Patrick。

你的解决方案很好!

$http.post(config.serverUrl + "/admin/saveconfigtable/" + key +"/" + encodeURIComponent(data));