Post an array of complex objects with JSON, JQuery to ASP.NET MVC Controller

前端 未结 1 1582
被撕碎了的回忆
被撕碎了的回忆 2020-12-19 14:28

I know this issue has been touched on before, e.g. here:

How to post an array of complex objects with JSON, jQuery to ASP.NET MVC Controller?

But the soluti

相关标签:
1条回答
  • 2020-12-19 15:02

    You can serialize the form as Vikas posted, or you could use a stringify function if you'd prefer to walk the page (as you are currently doing) and use the postData array.

    On the controller, you'll need to handle the json string. You can use the System.Web.Script.Serialization.JavaScriptSerializer class to deserialize it. If you have an object that maps to the data you're passing, you can use the Deserialize method. If you don't, you can still use DeserializeObject, however that gives you a Dictionary<string, string> collection that you'll have to walk through to get your data. Not exactly fun (trust me), but it works.

    0 讨论(0)
提交回复
热议问题