简体   繁体   English

如何读取表单URL编码的响应

[英]How to read form-url encoded response

I am making HTTP Post request to Rest service 我正在发出HTTP Post请求到Rest服务

Content: application/x-www-form-urlencoded Accept: application/x-www-form-urlencoded 内容:application / x-www-form-urlencoded接受:application / x-www-form-urlencoded

I get response in below format 我收到以下格式的回复

"{\\r\\n\\t\\"status\\":\\"Success\\"\\r\\n}" “{\\ r \\ n \\吨\\” 状态\\ “:\\” 成功\\ “\\ r \\ N}”

Is there any good way to load this string and read status 有什么好的方法可以加载此字符串并读取状态

Check out the Json.Net library: http://james.newtonking.com/json (Nuget: Newtonsoft.Json) 查看Json.Net库: http ://james.newtonking.com/json(Nuget:Newtonsoft.Json)

You could digest the response into a dynamic class: 您可以将响应摘要为一个动态类:

var testData = "{\r\n\t\"status\":\"Success\"\r\n}";
dynamic testObject = JsonConvert.DeserializeObject(testData);
Console.WriteLine(testObject.status); //Success
Console.ReadKey();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM