我正在使用Newtonsoft JSON.NET来创建一个看起来很好的动态JSON对象,但是当我将它发送到REST API时却无法识别。我最好的猜测是JSON字符串中有新行,它打破了API用于解析数据的过程。有没有办法确保从我发送的JSON数据中删除所有新行?
dynamic MyPerson = new JObject();
MyPerson.username = "CodeMonkey";
MyPerson.first_name = "Monkey";
MyPerson.last_name = "banana";
MyPerson.email_address = "bananacrazy@monkey.com";
MyPerson.is_active = true;
string PersonData = JsonConvert.SerializeObject(MyPerson);
如果我使用Response.Write,它返回的JSON是:
{"username":"CodeMonkey","first_name":"Monkey","last_name":"Banana","email_address":"monkey@bananacrazy.com","is_active":true}