I'm not very good at this yet, not sure if my subject even accurately describes what I need. I know it's probably been answered, I'm having a hard time understanding the answers since they don't directly apply to my data. I am trying to figure out how I can iterate through the data in this URL.
This is what I've been using.
Dim url = "http://tmi.twitch.tv/group/user/" & ConnectionInformation.Channel.TrimStart("#") & "/chatters"
Dim json As String = Nothing
Dim wc As New WebClient()
json = wc.DownloadString(url)
Dim root As JToken = JToken.Parse(json)
For Each item As JToken In root("chatters")
'I've tried several things here and I can't find a good way to iterate through the viewers found here.
I guess I'm having trouble getting the viewers in a collection so that I can iterate through them, can someone point me in the right direction here?
Best How To :
"Chatters" is actually a Type in the root object. If you were to create classes, they would look like this:
Public Class RootChatter
Public Property _links As _Links
Public Property chatter_count As Integer
Public Property chatters As Chatters
Public Class _Links
Public Class Chatters
Public Property moderators As String()
Public Property staff As String()
Public Property admins As String()
Public Property global_mods As String()
Public Property viewers As String()
Viewers is an array in the Chatters Property (
Root.Chatters.Viewers). Without the class:
Dim root As JToken = JToken.Parse(jstr)
Dim chatters = root("chatters")("viewers")
For n As Integer = 0 To chatters.Count - 1
If you were to deserialize to the classes:
Dim jc = JsonConvert.DeserializeObject(Of RootChatter)(jstr)
Dim viewers = jc.chatters.viewers