Hi,
Have an interesting project here. I am trying to write an app to go onto a Motorola scanner that runs .Net Compact 3.5. I have to work with a REST API and am having issues with Deserializing the json to the classes that I have written using Json.Net 3.5 R8 (this is the last version of Json.Net that supported .Net Compact). Below is the classes that I have written:
Public Class ResponseProperties
Public Property Status() As String
Get
Return m_Status
End Get
Set(ByVal value As String)
m_Status = value
End Set
End Property
Private m_Status As String
Public Property Nsid() As String
Get
Return m_Nsid
End Get
Set(ByVal value As String)
m_Nsid = value
End Set
End Property
Private m_Nsid As String
Public Property Message() As String
Get
Return m_Message
End Get
Set(ByVal value As String)
m_Message = value
End Set
End Property
Private m_Message As String
Public Property RecordType() As String
Get
Return m_RecordType
End Get
Set(ByVal value As String)
m_RecordType = value
End Set
End Property
Private m_RecordType As String
Public Property BinNumber() As String
Get
Return m_BinNumber
End Get
Set(ByVal value As String)
m_BinNumber = value
End Set
End Property
Private m_BinNumber As String
Public Property ExternalID() As Integer
Get
Return m_ExternalID
End Get
Set(ByVal value As Integer)
m_ExternalID = value
End Set
End Property
Private m_ExternalID As Integer
End Class
Public Class Response
Public Property responce() As ResponseProperties()
Get
Return m_responce
End Get
Set(ByVal value As ResponseProperties())
m_responce = value
End Set
End Property
Private m_responce As ResponseProperties()
End Class
and here is the code that I am using to deserialize the json:
Imports Newtonsoft.Json
Imports System.Net
Imports System.IO
Imports System.Text
Public Class Form1
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim Json As String = txtjson.Text
Dim ResponcesRes = JsonConvert.DeserializeObject(Of Response)(Json)
lblOutput.Text = "output" & vbNewLine & ResponcesRes.responce(1).BinNumber
End Sub
End Class
Here is an example of the Json that I am receiving.
{"response":[{"status":"success","nsid":"22222","message":"message here","recordtype":"bin","type":"create","binnumber":"binname","externalid":1111},{"status":"success","nsid":"22222","message":"message here","recordtype":"bin","type":"create","binnumber":"binname","externalid":1111},{"status":"success","nsid":"22222","message":"message here","recordtype":"bin","type":"create","binnumber":"binname","externalid":1111},{"status":"success","nsid":"22222","message":"message here","recordtype":"bin","type":"create","binnumber":"binname","externalid":1111},{"status":"success","nsid":"22222","message":"message here","recordtype":"bin","type":"create","binnumber":"binname","externalid":1111},{"status":"success","nsid":"22222","message":"message here","recordtype":"bin","type":"create","binnumber":"binname","externalid":1111}]}
The code does not Error I Just don't get any output. if i=I hover the mouse over the ResponcesRes it tells me that it contains Nothing.
If there is more information needed please ask.
What I have tried:
Have tried to changed the Class Structure but this has not helped resolve the issue.