Trying to convert a JSON string into an object in C#. Using a really simple test case:
JavaScriptSerializer json_serializer = new JavaScriptSerializer(); object routes_list = json_serializer.DeserializeObject("{ "test":"some data" }");
The problem is that routes_list never gets set; it's an undefined object. Any ideas?
Or, you can use the Newtownsoft.Json library as follows:
using Newtonsoft.Json; ... var result = JsonConvert.DeserializeObject<T>(json);
Where T is your object type that matches your JSON string.
T
2.1m questions
2.1m answers
60 comments
57.0k users