Quantcast
Channel: How can I deserialize JSON to a simple Dictionary in ASP.NET? - Stack Overflow
Viewing all articles
Browse latest Browse all 23

Answer by northben for How can I deserialize JSON to a simple Dictionary in ASP.NET?

$
0
0

I just implemented this in RestSharp. This post was helpful to me.

Besides the code in the link, here is my code. I now get a Dictionary of results when I do something like this:

var jsonClient = new RestClient(url.Host);jsonClient.AddHandler("application/json", new DynamicJsonDeserializer());var jsonRequest = new RestRequest(url.Query, Method.GET);Dictionary<string, dynamic> response = jsonClient.Execute<JObject>(jsonRequest).Data.ToObject<Dictionary<string, dynamic>>();

Be mindful of the sort of JSON you're expecting - in my case, I was retrieving a single object with several properties. In the attached link, the author was retrieving a list.


Viewing all articles
Browse latest Browse all 23

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>