截断变量中的数据,无法获得完整数据

时间:2017-09-11 06:44:06

标签: json typescript post nativescript angular2-forms

我是nativescript angular2编程的新手。我想将大型json数据发布到服务器。但是当我创建一个json格式数据时,数据会被截断。我认为原因是持有变量的大小。

//我的代码是:

let headers = new Headers({ "Content-Type": "application/json" });
let options = new RequestOptions({ headers: headers });
let body= 
{
  "id": "1002345",
  "weekday": [{
    "item1" :" data1",//string
    "item2":" data2",//string
    "item3":" data3",//string
    "item4":" data4",//string
    "item5":" data5",//string
    "item6":" data6",//base64 string of an image
    "item7":" data7"//base64 string of an image
}]

};

当我尝试打印body时,数据会被截断!! 1.哪个变量可以容纳大数据? 2.发布大数据的任何替代方法? 请帮帮我。

// json格式: {"id":"1002345","weekday":{"item1":"nil","item2":"nil","item3":"nil","item4":"nil","item5":0,"item6":"nil","item7":"nil"}}

//实际的Json数据:

{"id":"1002345","weekday":{"item1":"nil","item2":"nil","item3":"nil","item4":"nil","item5":0,"item6":"iVBORw0KGgoAAAANSUhEUgAAAlgAAAEsCAYAAAAfPc2WAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAWJQAAFiUBSVIk8AAAABxpRE9UAAAAAgAAAAAAAACWAAAAKAAAAJYAAACWAAAQl/KErzoAABBjSURBVHgB7N0HrHRFFQBgioIovaggBA0gAQOKYCUYCSKCFWxgQFHsiEYg1sQaJUYUhQgCIoaggtg7KCJFBYTYEguiQAgWooKoIBb0HH0L6/PM//+7b997u/d+k5zsvrlz5875IPlPdu/OXW01jQABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIE

这里是item6的一部分而item7缺失了!

1 个答案:

答案 0 :(得分:1)

如果是"当我尝试打印body"你的意思是你用console.log()输出它需要注意的是,在大多数系统(包括Chrome,Firefox,IE,甚至是nodejs)上,来自console.log()的调试输出被截断以防止它超过合理的长度用于显示。

除非您有其他理由相信您的变量已被截断,否则可能还没有。