Hi Everyone,
I have some JSON coming from the server that looks like this:
{
“data”: {
“amount”: “1015.00”,
“currency”: “USD”
}
}
I need to be able to extract the “amount” element from it and I’m not quite sure how to do it. So far, I have the following code:
Dim serverResponse as String
Dim jsonObject as JSONItem
Dim webSocket as new HTTPSecureSocket
Dim currentPrice as String
Dim serverURI as String
webSocket.Secure = True
serverURI = “https://someserver.com”
serverResponse = webSocket.Get (serverURI, 15)
Try
jsonObject = new jsonItem(serverResponse)
currentPrice = jsonObject.Child(“data”).Child(“amount”).ToString
catch ex as JSONException
MsgBox(“Cannot retrieve the price.”)
finally
webSocket = Nil
jsonItem = Nil
end Try
This is returning an error and I think it’s because I’m not accessing “amount” in the correct way. Can anyone lend me a hand and explain how I would access the “amount” element in the above JSON?
Sorry for the lack of indentation. I don’t know how to get my spaces to actually show proper indentation in these forum posts. It looks horrid and I apologize.
Thanks!
Dave