在C#中将对象转换为Json并通过POST发送它会导致一个损坏的对象?

在C#上,我正在打印正在发送到控制台的JSONifiedstring,它的内容如下所示

{ "message" : "done", "numSlides" : 1, "slides" : [{ "num" : 1, "key" : "530d8aa855df0c2d269a5a5853a47a469c 52c9d83a2d71d9/1slide/Slide1_v8.PNG" }], "bucket" : "xx.xxxxxxxxxx", "error" : null, "wedge" : false, "tenant" : null, "name" : null } 

然后我这样做将其转换为一个字节数组并发送它

 WebRequest request = WebRequest.Create(Program.api +"/"+ route); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; //Get the request stream Stream dataStream = request.GetRequestStream(); byte[] byteArray = Encoding.UTF8.GetBytes(myString); dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Close(); 

而在node.js方面,我得到这个时console.logging res.body:

 { '{ "message" : "done", "numSlides" : 1, "slides" : ': { '{ "num" : 1, "key" : "530d8aa855df0c2d269a5a5853a47a469c52c9d83a2d71d9/1slide/Slide1_v8.PNG" }], "bucket" : "xx.xxxxxxxxxx", "error" : null, "wedge" : false, "tenant" : null, "name" : null ': '' } } 

这看起来不像有效的JSON。 发生了什么? 我怎样才能发送和接收正确的数据?

在testing我正在写的节点服务器时,我遇到了类似的问题。 问题最终与请求的内容types有关。 我相信这也可能是你的问题。

我在想你想要的内容types是“application / json”。

看到这个职位了解更多信息