I have a simple key/value list in JSON being sent back to ASP.NET via POST. Example:
{ \"key1\": \"value1\", \"key2\": \"value2\"}
I did discover .NET has a built in way to cast the JSON string into a Dictionary
via the System.Web.Script.Serialization.JavaScriptSerializer
type in the 3.5 System.Web.Extensions
assembly. Use the method DeserializeObject(String)
.
I stumbled upon this when doing an ajax post (via jquery) of content type 'application/json' to a static .net Page Method and saw that the method (which had a single parameter of type Object
) magically received this Dictionary.