【发布时间】:2014-05-24 04:10:00
【问题描述】:
我有这样的 JSON 字符串:
'{"1":[1,3,5],"2":[2,5,6],"3":[5,6,8]}'
我想将其发送到 Web Api Controller 而不使用 ajax 请求进行更改:
$.ajax({
type: "POST",
url: "Api/Serialize/Dict",
data: JSON.stringify(sendedData),
dataType: "json"
});
在 Web Api 我有这样的方法:
[HttpPost]
public object Dict(Dictionary<int, List<int>> sendedData)
{
//code goes here
return null;
}
而且总是sendedData == null. 换句话说:我不知道如何将JSON反序列化为(Dictionary<int, List<int>>。
谢谢你的回答。
【问题讨论】:
-
试图解决这个问题一段时间 - 然后阅读:stackoverflow.com/questions/4710729/post-json-dictionary
-
是的,Web API 上的 JSON 似乎已损坏。
标签: javascript c# jquery json asp.net-web-api