VbNet · Console
Imports System
Imports System.Linq
Imports System.Collections.Generic
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq
Imports Newtonsoft.Json.Converters
Imports Newtonsoft.Json.Serialization
' https://stackoverflow.com/questions/38944981/accessing-nested-object-in-vb-net-from-newtonsoft-json
Public Class Url2
Public Property href As String
End Class
Public Class Test1
Public Property url2 as Url2
End Class
Public Module Module1
Public Sub Main()
dim JSON as string = "{""url2"": {""href"": ""https://example.com/test2/""}}"
Dim objURL1 = Newtonsoft.Json.JsonConvert.DeserializeObject(Of Test1)(JSON)
dim href = objURL1.url2.href
dim JSON2 = Newtonsoft.Json.JsonConvert.SerializeObject(objURL1, Formatting.Indented)
Console.WriteLine("objURL1.url2.href:")
Console.WriteLine(href)
Console.WriteLine("")
Console.WriteLine("Deserialized and re-serialized JSON:")
Console.WriteLine(JSON2)
End Sub
End Module