What is the simplest C# function to parse a JSON string into an object?
.net, c#, json, wpf
Solution
DataContractJsonSerializer serializer =
new DataContractJsonSerializer(typeof(YourObjectType));
YourObjectType yourObject = (YourObjectType)serializer.ReadObject(jsonStream);
You could also use the `JavaScriptSerializer`, but `DataContractJsonSerializer` is supposedly better able to handle complex types.
Oddly enough JavaScriptSerializer was once deprecated (in 3.5) and then resurrected because of ASP.NET MVC (in 3.5 SP1). That would definitely be enough to shake my confidence and lead me to use `DataContractJsonSerializer` since it is hard baked for WCF.
Problem
What is the simplest C# function to parse a JSON string into a object and display it (C# XAML WPF)? (for example object with 2 arrays - arrA and arrB)