following is me JSON response text. I validated response and there is no error. I am trying to convert it to data table but it gives me null or error.
JSON Response:
{
"data": {
"b2b": [
{
"inv": [
{
"itms": [
{
"num": 1,
"itc": {
"tx_cs": 0,
"elg": "ip",
"tx_i": 180
},
"itm_det": {
"csamt": 0,
"rt": 18,
"txval": 1000,
"iamt": 180
}
}
],
"val": 1000,
"inv_typ": "R",
"flag": "N",
"updby": "S",
"pos": "27",
"idt": "24-07-2017",
"rchrg": "N",
"cflag": "U",
"inum": "191001",
"chksum": "52d0e920428464d85721bfcd7f3bfb4f16fd00d93a9df7d6a6f0814bed716c28"
},
{
"itms": [
{
"num": 1,
"itc": {
"tx_cs": 0,
"elg": "ip",
"tx_i": 18
},
"itm_det": {
"csamt": 0,
"rt": 18,
"txval": 100,
"iamt": 18
}
}
],
"val": 100,
"inv_typ": "R",
"flag": "N",
"updby": "S",
"pos": "27",
"idt": "24-07-2017",
"rchrg": "N",
"cflag": "U",
"inum": "191002",
"chksum": "aaa1efcf335549b58059c9f3d03807d7c41b007022216f8a90db12c60cd2b9ef"
}
],
"cfs": "N",
"ctin": "1225586"
}
]
},
"header": {
"email": "[email protected]",
"gstin": "65656451",
"retperiod": "072017",
"gst_username": "sampleaccount",
"state_cd": "27",
"ip_address": "192.168.2.200",
"txn": "s4f5sdf54sdf5s4df5",
"client_id": "removedfortest",
"client_secret": "removedfortest",
"authorization": "Basic a4s5df45asdf54as5d4f",
"ret_period": "072017"
},
"status_cd": "1",
"status_desc": "request succeeds"
}
Following are the classes i defined
Public Class Itc
Public Property tx_cs As Integer
Public Property elg As String
Public Property tx_i As Integer
End Class
Public Class ItmDet
Public Property csamt As Integer
Public Property rt As Integer
Public Property txval As Integer
Public Property iamt As Integer
End Class
Public Class Itm
Public Property num As Integer
Public Property itc As Itc
Public Property itm_det As ItmDet
End Class
Public Class Inv
Public Property itms As Itm()
Public Property val As Integer
Public Property inv_typ As String
Public Property flag As String
Public Property updby As String
Public Property pos As String
Public Property idt As String
Public Property rchrg As String
Public Property cflag As String
Public Property inum As String
Public Property chksum As String
End Class
Public Class B2b
Public Property inv As Inv()
Public Property cfs As String
Public Property ctin As String
End Class
Public Class Data
Public Property b2b As B2b()
End Class
Public Class Header
Public Property email As String
Public Property gstin As String
Public Property retperiod As String
Public Property gst_username As String
Public Property state_cd As String
Public Property ip_address As String
Public Property txn As String
Public Property client_id As String
Public Property client_secret As String
Public Property authorization As String
Public Property ret_period As String
End Class
Public Class Example
Public Property data As Data
Public Property status_cd As String
Public Property status_desc As String
Public Property header As Header
End Class
and then i am trying to do following:
Following return me Null in datatable
Dim table as datatable = JsonConvert.DeserializeObject(Of RootObject(Of DataTable))(responsetext).Table
also tried: following does not allow me to type in rootofTable.data
Dim rootOfList = JsonConvert.DeserializeObject(Of RootObject(Of List(Of data)))(responsetext)
Dim table As DataTable = rootOfTable.data
None of these are returning me values to datatable. Dataset stay null.
Please help to resolve.
Thanks

