Simple working Example of json.net in VB.net
Your class JSON_result
does not match your JSON string. Note how the object JSON_result
is going to represent is wrapped in another property named "Venue"
.
So either create a class for that, e.g.:
Public Class Container
Public Venue As JSON_result
End Class
Public Class JSON_result
Public ID As Integer
Public Name As String
Public NameWithTown As String
Public NameWithDestination As String
Public ListingType As String
End Class
Dim obj = JsonConvert.DeserializeObject(Of Container)(...your_json...)
or change your JSON string to
{
"ID": 3145,
"Name": "Big Venue, Clapton",
"NameWithTown": "Big Venue, Clapton, London",
"NameWithDestination": "Big Venue, Clapton, London",
"ListingType": "A",
"Address": {
"Address1": "Clapton Raod",
"Address2": "",
"Town": "Clapton",
"County": "Greater London",
"Postcode": "PO1 1ST",
"Country": "United Kingdom",
"Region": "Europe"
},
"ResponseStatus": {
"ErrorCode": "200",
"Message": "OK"
}
}
or use e.g. a ContractResolver
to parse the JSON string.
Imports Newtonsoft.Json.Linq
Dim json As JObject = JObject.Parse(Me.TextBox1.Text)
MsgBox(json.SelectToken("Venue").SelectToken("ID"))