Hello,
How to access value from JSON element with space in naming
I have integrated with an API and the returned JSON data i am getting some elements have spacing in between them.
for example. Order Id,Convenience Fee, i find it difficult to read the value of the element.
Please find bellow my code and the structure of the JSON data.
Dim GetURL As String = "https://sample.com/Status/" & txtPaymentrefrence.Text
Dim myGETRequest As HttpWebRequest = CType(WebRequest.Create(GetURL), HttpWebRequest)
myGETRequest.Method = "GET"
myGETRequest.Accept = "application/json"
Dim GETresponse As HttpWebResponse = CType(myGETRequest.GetResponse(), HttpWebResponse)
Dim GETStream As Stream = GETresponse.GetResponseStream()
Dim ReadGETstream As StreamReader = New StreamReader(GETStream, Text.Encoding.UTF8)
Dim JResult As String = ReadGETstream.ReadToEnd()
Dim Result As PaymentJSONresponce = Deserialize(Of PaymentJSONresponce)(JResult)
txtAmount.Text = Result.Amount
txtDescription.Text = Result.Description
txtScheme.Text = Result.Scheme
txtStatus.Text = Result.Status
txtTranDateTime.Text = Result.TranDateTime
txtPAN.Text = Result.PAN
txtJSON.Text = JResult.ToString
Public Class PaymentJSONresponce
Public Property OrderId As String
Public Property Amount As Decimal
Public Property Description As String
Public Property TranDateTime As DateTime
Public Property Status As String
Public Property Holder As String
Public Property PAN As String
Public Property Scheme As String
Public Property StatusDescription As String
Public Property Channel As String
Public Property Reference As String
End Class
JSON DATA
{
"Order Id":"6183873",
"Amount":"2500.00",
"Description":" UTME/DE Reg. Data Corrections^2021562611509592",
"Convenience Fee":"0.00",
"Currency":"566",
"Status":"APPROVED",
"Card Holder":"",
"PAN":"",
"Scheme":"MC",
"TranTime":"7/3/2021 3:42:20 PM",
"StatusDescription":"APPROVED"
}
THOSE ELEMENT ARE HARD TO GET