I try to read json array which return from RestResponse using following code , i am used RestClient to call POST method
Dim clientPI As RestClient = New RestClient("https://sampleurl")
Dim requestPI = New RestRequest(Method.POST)
requestPI.AddParameter("name", "Aravind")
requestPI.AddParameter("username", "aravind")
requestPI.AddParameter("password", "aravind123")
requestPI.AddParameter("id", "100")
Dim responsePI As RestResponse = clientPI.Execute(requestPI)
Dim StrReturnPI As JValue = responsePI.Content.ToString
Dim serPI As JObject = JObject.Parse(StrReturnPI)
Dim dataPI As List(Of JToken) = serPI.Children().ToList
For Each item As JProperty In dataPI
item.CreateReader()
Select Case item.Name
Case "result"
output += "Document_id:" + vbCrLf
For Each comment As JObject In item.Values
Dim u As String = comment("Document_id")
output += u + vbTab
Next
Case "Inv_Date"
output += "Inv_Date:" + vbCrLf
For Each msgDate As JObject In item.Values
Dim f As String = msgDate ("value")
output += f + vbTab
Next
Case "Inv_Number"
output += "Inv_Number:" + vbCrLf
For Each msg As JObject In item.Values
Dim f As String = msg("value")
output += f + vbTab
Next
End Select
Next
Sample Json
{{
"result": [
{
"Document_id": "598dce483b97c",
"file_name": "2022-04-04_09_13_14.847228.pdf",
"Inv_Date": {
"value": "15-Jul-2019",
},
"Inv_Number": {
"value": "1920021347",
}
}
]],
"status": "complete"
}}
From above code i can read only value from Document_id and file_name but cant read value from Inv_Date and Inv_Number.
Anyone help will be appreciated.
Thanks and regards Aravind