我将字典发布到C# Web 服务器中,想问如何获取POST 字典?
下面是我的示例字典
{"Debtor":{"CompanyName":"Big Company","AccNo":"300-G002","DocDate":"26-November-2012"}}
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "json/PostSalesOrderData", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
Dictionary<string, Object.Test> PostSalesOrderData(object data);
public Dictionary<string, Object.Test> PostSalesOrderData(object data)
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
string str = serializer.Serialize(data);
Dictionary<string, Object.Test> userData = serializer.Deserialize<Dictionary<string, Object.Test>>(str);
return userData;
}
Xcode 响应字符串
服务器在处理请求时遇到错误。异常消息是“反序列化 System.Object 类型的对象时出错。令牌 '"' 是预期的,但发现是 'D'。'。有关更多详细信息,请参阅服务器日志。异常堆栈跟踪是: