selecttoken em vbnet e json
Option Strict On
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq
Imports System.Net.Http
Imports System.IO
Module Module1
Sub Main()
Dim t = JsonTestAsync()
Console.ReadKey()
End Sub
Private Async Function JsonTestAsync() As Task
Using client As New HttpClient
Dim response = Await client.GetAsync("https://atlas.metabroadcast.com/3.0/channel_groups/cbhJ.json?apiKey={insert your API key}&annotations=channels")
Using reader As New StreamReader(Await response.Content.ReadAsStreamAsync)
Using jsonreader = New JsonTextReader(reader)
Dim serializer = New JsonSerializer()
Dim document As JObject = CType(serializer.Deserialize(jsonreader), JObject)
For Each result In document
Console.WriteLine(result.Key)
For Each channelgroup In result.Value
Console.WriteLine("Title = " & channelgroup.Item("title").ToString)
Console.WriteLine("ID = " & channelgroup.Item("id").ToString)
For Each channel In channelgroup.Item("channels")
Dim first = channel.Children.First
Dim titleInfo = first.Children.First
Dim numberInfo = first.Next
Console.WriteLine(numberInfo.Children.First.ToString & " = " & titleInfo.Item("title").ToString)
Next
Next
Next
End Using
End Using
End Using
End Function
End Module