I am trying to parse the JSON data from a website. I successfully get the JSON string, but I can't parse it. An exception is thrown in the code below:
Runtime Error 424. Object Required
This is my code:
' Download string from URL
Public Function DownloadDataFromURL(url As String) As String
Set Myrequest = CreateObject("WinHttp.WinHttpRequest.5.1")
Myrequest.Open "GET", url
Myrequest.send
Dim WebResponse As String
WebResponse = Myrequest.responseText
Cells(1, 1).Value = WebResponse
DownloadDataFromURL = WebResponse
End Function
' Download all cryptocoins in
Public Sub LoadCryptocoins()
Dim Path As String
Dim Data As String
Dim json As Object
Path = "https://api.coinmarketcap.com/v1/ticker/"
Data = DownloadDataFromURL(Path)
Set jp = New JsonParser
Set jo = jp.Decode(Data)
For Each Item In jp.EnumKeys(jo)
MsgBox (Item.GetValue(jo, "id")) 'The exception is thrown here
Next
End Sub
I'm using the JSON Parser from here: Parsing JSON in Excel VBA
The raw JSON data I a processing can be found here: https://api.coinmarketcap.com/v1/ticker/
How can I get every coin name and the price in USD?