[Help] Deserializing multilevel JSON data with RestSharp

Obligatory "I'm on mobile so ignore my mistakes" notice.

I am pretty new to programming and haven't quite wrapped my head around arrays and dictionaries. They are my weak point for sure. I have started to make some programs to further my learning and I'm not sure how to get this to work.

I an making a simple WPF app that will take a list of followers from a channel on hitbox.tv, will show them in a list and will then pick a random one from the list as a winner.

Source: Hitbox channel

My broken, noobish attempt at code:

internal static string GetFollowers(string channel) { var client = new RestClient(@"http://ift.tt/1AS1kVH;); var request = new RestRequest(@"followers/user/{channel}", Method.GET); request.RequestFormat = RestSharp.DataFormat.Json; request.AddParameter("channel", channel, ParameterType.UrlSegment); var response = client.Execute(request); RestSharp.Deserializers.JsonDeserializer deserial = new RestSharp.Deserializers.JsonDeserializer(); var FollowList = deserial.Deserialize<Dictionary<string, string>>(response); string followers = FollowList["user_name"]; return followers; 

I hope that displays properly…

So, where did I go wrong and how do I fix it? Also, what is the best way to display this list in WPF? ListBox? TextBlock?

Hit me with anything I might have forgotten to include and I'll get back to you. Many thanks!

by AquatikJustice via /r/csharp

Leave a Reply