Imports System.Collections.Generic
Imports Newtonsoft.Json.Linq
Imports Newtonsoft.Json.Converters
Imports Newtonsoft.Json.Serialization
Public Property kind As String
Public Property etag As String
Public Property pageInfo As Pageinfo
Public Property items As Item()
Public Property totalResults As Integer
Public Property resultsPerPage As Integer
Public Property kind As String
Public Property etag As String
Public Property id As String
Public Property snippet As Snippet
Public Property contentDetails As Contentdetails
Public Property publishedAt As Date
Public Property channelId As String
Public Property title As String
Public Property description As String
Public Property thumbnails As Thumbnails
Public Property channelTitle As String
Public Property tags As String()
Public Property categoryId As String
Public Property liveBroadcastContent As String
Public Property localized As Localized
Public Property _default As _Default
Public Property medium As Medium
Public Property high As High
Public Property standard As Standard
Public Property maxres As Maxres
Public Property url As String
Public Property width As Integer
Public Property height As Integer
Public Property url As String
Public Property width As Integer
Public Property height As Integer
Public Property url As String
Public Property width As Integer
Public Property height As Integer
Public Property url As String
Public Property width As Integer
Public Property height As Integer
Public Property url As String
Public Property width As Integer
Public Property height As Integer
Public Property title As String
Public Property description As String
Public Class Contentdetails
Public Property duration As String
Public Property dimension As String
Public Property definition As String
Public Property caption As String
Public Property licensedContent As Boolean
Public Property regionRestriction As Regionrestriction
Public Property projection As String
Public Class Regionrestriction
Public Property allowed As String()
Dim json = JToken.Parse("{""kind"":""youtube#videoListResponse"",""etag"":""\""m2yskBQFythfE4irbTIeOgYYfBU/jznkhy3_Aws9VtommTkcdOYnAAk\"""",""pageInfo"":{""totalResults"":1,""resultsPerPage"":1},""items"":[{""kind"":""youtube#video"",""etag"":""\""m2yskBQFythfE4irbTIeOgYYfBU/M_wQmC4lQBaHJGxo79N7WlmqNr8\"""",""id"":""SSbBvKaM6sk"",""snippet"":{""publishedAt"":""2009-04-15T20:31:11Z"",""channelId"":""UC2kTZB_yeYgdAg4wP2tEryA"",""title"":""Blur - Song 2"",""description"":""Blur 21 -- Celebrating 21 years of Blur. To find out more, click here:http://smarturl.it/blur21y\n\n#blur21\n \nFollow Blur on Twitter:www.twitter.com/blurofficial \nFind Blur on Facebook:www.facebook.com/blur\n\nMusic video by Blur performing Song 2."",""thumbnails"":{""default"":{""url"":""https://i.ytimg.com/vi/SSbBvKaM6sk/default.jpg"",""width"":120,""height"":90},""medium"":{""url"":""https://i.ytimg.com/vi/SSbBvKaM6sk/mqdefault.jpg"",""width"":320,""height"":180},""high"":{""url"":""https://i.ytimg.com/vi/SSbBvKaM6sk/hqdefault.jpg"",""width"":480,""height"":360},""standard"":{""url"":""https://i.ytimg.com/vi/SSbBvKaM6sk/sddefault.jpg"",""width"":640,""height"":480},""maxres"":{""url"":""https://i.ytimg.com/vi/SSbBvKaM6sk/maxresdefault.jpg"",""width"":1280,""height"":720}},""channelTitle"":""emimusic"",""tags"":[""Blur"",""Song""],""categoryId"":""10"",""liveBroadcastContent"":""none"",""localized"":{""title"":""Blur - Song 2"",""description"":""Blur 21 -- Celebrating 21 years of Blur. To find out more, click here:http://smarturl.it/blur21y\n\n#blur21\n \nFollow Blur on Twitter:www.twitter.com/blurofficial \nFind Blur on Facebook:www.facebook.com/blur\n\nMusic video by Blur performing Song 2.""}},""contentDetails"":{""duration"":""PT2M3S"",""dimension"":""2d"",""definition"":""sd"",""caption"":""false"",""licensedContent"":true,""regionRestriction"":{""allowed"":[""BY"",""US""]},""projection"":""rectangular""}}]}").ToString()
Dim root = JsonConvert.DeserializeObject(Of Rootobject)(json)
Dim titles = root.items _
.Select(Function(i) i.snippet.title) _
Dim firstTitle = titles.FirstOrDefault()
Console.WriteLine("First title = ""{0}""", firstTitle)
Dim json2 = JsonConvert.SerializeObject(root, Formatting.Indented)
Console.WriteLine("Reserialized JSON: ")
Console.WriteLine("Json.NET version: " + GetType(JsonSerializer).Assembly.FullName)