This should be straightforward but I can't figure it out.
I have a simple JSON array: [{"carId":1,"status":"Active","inventory":"3"}, {"carId":2,"status":"Active","inventory":"5"}]
I have my JSON classes:
Friend Class carModel
Public Property carId As String
Public Property status As String
Public Property inventory As String
End Class
Friend Class carWrapper
Friend arrcarModel() As carModel
End Class
And I have the following code:
Dim currentWrapper = DeserializeObject(Of List(Of carWrapper))(strJSON)
If currentWrapper.Count > 0 Then
For i As Integer = 0 To RXWrapper.Count - 1
Dim carItem = currentWrapper(i).arrcarModel
Next
End If
Although the code does indeed result with currentWrapper.Count = 2, currentWrapper(i).arrcarModel always winds up equal to Nothing.
What am I not doing correctly? Is there a more standard approach to deserializing a JSON array?
Thanks!
carModelobjects. I.e., you don't needcarWrapper.Dim cardModels = JsonConvert.DeserializeObject(Of List(Of CarModel))(strJSON).