JSON解析POST请求C# [英] Parsing JSON POST request C#
本文介绍了JSON解析POST请求C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有些serwer发送POST请求包含以下信息:
Some serwer sends POST requests with the following information:
{
payload: {
uid: "900af657a65e",
amount: 50,
adjusted_amount: 25
},
signature: "4dd0f5da77ecaf88628967bbd91d9506"
}
我如何768,16成功处理,在我的ASHX处理程序?
How shoud I successfully process that in my ASHX handler?
推荐答案
由于SLaks指出,这不是有效的JSON。但在一般情况下,序列化/ .NET中的反序列化JSON一个很好的解决方案是JSON.NET库: http://json.codeplex.com/ 。有大量的文档,应该让你开始说的。
As SLaks noted, that's not valid JSON. But in general, a good solution for serializing/deserializing JSON in .NET is the JSON.NET library: http://json.codeplex.com/. There is plenty of documentation there that should get you started.
编辑:读取请求主体,尝试像
to read the request body, try something like
string postData = new System.IO.StreamReader(context.Request.InputStream).ReadToEnd();
这篇关于JSON解析POST请求C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文