I'm trying to use VB.NET to access some deserialized data using newtonsoft's JSON library. So far I've gotten the JSON data deserialized and the data appears to be valid in the debugger, I just have no clue how to access it.
Basically, what I'm trying to do is I'm accessing twitch.tv's API to fetch a list of games, maybe into an array, and then get those games into a combo box.
This code is the result of a lot of googling and a c# to VB converter for the deserialization classes. Can anybody help me figure out what I need to do to access the names of the games in this chunk of data?
Imports Newtonsoft.Json
Imports System.IO
Public Class search
Private Sub search_Load(s Ender As Object, e As EventArgs) Handles MyBase.Load
getTwitchGames()
End Sub
Private Function getTwitchGames() As Array
Dim strQueryURL As String = "https://api.twitch.tv/kraken/games/top"
'create web request object and s End the request
Dim webclient As New System.Net.WebClient
Dim json As String = webclient.DownloadString(strQueryURL)
'Parse the result
Dim test As RootObject = JsonConvert.DeserializeObject(Of RootObject)(json)
End Function
End Class
Public Class Links
Public Property self() As String
Get
Return m_self
End Get
Set(value As String)
m_self = Value
End Set
End Property
Private m_self As String
Public Property [next]() As String
Get
Return m_next
End Get
Set(value As String)
m_next = Value
End Set
End Property
Private m_next As String
End Class
Public Class Box
Public Property template() As String
Get
Return m_template
End Get
Set(value As String)
m_template = Value
End Set
End Property
Private m_template As String
Public Property small() As String
Get
Return m_small
End Get
Set(value As String)
m_small = Value
End Set
End Property
Private m_small As String
Public Property medium() As String
Get
Return m_medium
End Get
Set(value As String)
m_medium = Value
End Set
End Property
Private m_medium As String
Public Property large() As String
Get
Return m_large
End Get
Set(value As String)
m_large = Value
End Set
End Property
Private m_large As String
End Class
Public Class Logo
Public Property template() As String
Get
Return m_template
End Get
Set(value As String)
m_template = Value
End Set
End Property
Private m_template As String
Public Property small() As String
Get
Return m_small
End Get
Set(value As String)
m_small = Value
End Set
End Property
Private m_small As String
Public Property medium() As String
Get
Return m_medium
End Get
Set(value As String)
m_medium = Value
End Set
End Property
Private m_medium As String
Public Property large() As String
Get
Return m_large
End Get
Set(value As String)
m_large = Value
End Set
End Property
Private m_large As String
End Class
Public Class Links2
End Class
Public Class Game
Public Property name() As String
Get
Return m_name
End Get
Set(value As String)
m_name = Value
End Set
End Property
Private m_name As String
Public Property _id() As Integer
Get
Return m__id
End Get
Set(value As Integer)
m__id = Value
End Set
End Property
Private m__id As Integer
Public Property giantbomb_id() As Integer
Get
Return m_giantbomb_id
End Get
Set(value As Integer)
m_giantbomb_id = Value
End Set
End Property
Private m_giantbomb_id As Integer
Public Property box() As Box
Get
Return m_box
End Get
Set(value As Box)
m_box = Value
End Set
End Property
Private m_box As Box
Public Property logo() As Logo
Get
Return m_logo
End Get
Set(value As Logo)
m_logo = Value
End Set
End Property
Private m_logo As Logo
Public Property _links() As Links2
Get
Return m__links
End Get
Set(value As Links2)
m__links = Value
End Set
End Property
Private m__links As Links2
End Class
Public Class Top
Public Property viewers() As Integer
Get
Return m_viewers
End Get
Set(value As Integer)
m_viewers = Value
End Set
End Property
Private m_viewers As Integer
Public Property channels() As Integer
Get
Return m_channels
End Get
Set(value As Integer)
m_channels = Value
End Set
End Property
Private m_channels As Integer
Public Property game() As Game
Get
Return m_game
End Get
Set(value As Game)
m_game = Value
End Set
End Property
Private m_game As Game
End Class
Public Class RootObject
Public Property _total() As Integer
Get
Return m__total
End Get
Set(value As Integer)
m__total = Value
End Set
End Property
Private m__total As Integer
Public Property _links() As Links
Get
Return m__links
End Get
Set(value As Links)
m__links = Value
End Set
End Property
Private m__links As Links
Public Property top() As List(Of Top)
Get
Return m_top
End Get
Set(value As List(Of Top))
m_top = Value
End Set
End Property
Private m_top As List(Of Top)
End Class