简体   繁体   English

C#MVC-解析发布到控制器的json字典

[英]C# MVC - Parse a json dictionary posted to controller

I have a Javascript library that passes a dictionary in the post data like this: 我有一个Javascript库,可以在发布数据中像这样传递字典:

sort[columnName] = asc

If I do something like: 如果我做类似的事情:

[HttpPost]
public ContentResult tableData(Dictionary<string,string> sort)

It doesn't parse it. 它不会解析它。 Do I need to parse this by hand? 我需要手动解析吗? Or is there a way? 还是有办法?

I'm Sure this question has been asked before but due to the syntax it seems impossible to find. 我确定这个问题以前曾被问过,但由于语法原因,似乎找不到。

Never mind, found it. 没关系,找到了。 I am passing the parameters correctly and I do have the right format for the dictionary so there must be something completely different that is out somewhere. 我正确传递了参数,并且字典的格式正确,因此某些地方必须完全不同。 So this question is moot. 因此,这个问题尚无定论。 stackoverflow.com/a/18683004/881954 stackoverflow.com/a/18683004/881954

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

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