jamescooper
Well-known Member
- Joined
- Sep 8, 2014
- Messages
- 840
I am receiving this error message when pulling data from the web using JSON Convert:
Err.Raise 10001, "JSONConverter", json_ParseErrorMessage(json_String, json_Index, "Expecting 'STRING', 'NUMBER', null, true, false, '{', or '['")
This is the VBA I have:
Is there anything I can do to fix this please?
Many thanks.
Err.Raise 10001, "JSONConverter", json_ParseErrorMessage(json_String, json_Index, "Expecting 'STRING', 'NUMBER', null, true, false, '{', or '['")
This is the VBA I have:
Code:
Sub Dog_Form()
Dim LastRow As Long
Dim x As Long
Dim urls As Variant
Dim dogLinks As Variant
Application.ScreenUpdating = False
LastRow = Sheets("Races").Range("I" & Rows.Count).End(xlUp).row
urls = Sheets("Races").Range("I17:I19" & LastRow).Value
Sheets("Dog Form").Visible = True
For x = LBound(urls) To UBound(urls)
dogLinks = getDogForm(urls(x, 1))
Sheets("Dog Form").Cells(Sheets("Dog Form").Rows.Count, 1).End(xlUp).Offset(1).Resize(UBound(dogLinks), 20).Value2 = dogLinks
DoEvents
Next x
End Sub
Private Function getDogForm(ByVal url As String) As Variant
Dim forms As Collection
Dim form As Object
Dim ret() As Variant
Dim x As Long
Dim details As Object
Dim dogName As String
Dim trapNum As String
Dim dateOfBirth As String
Dim dogId As String
With CreateObject("msxml2.xmlhttp")
.Open "GET", url, False
.send
Set details = JSONConvert.ParseJson(.responseText)("details")
End With
Set forms = details("forms")
dogName = details("dogInfo")("dogName")
trapNum = details("dogInfo")("trapNum")
dateOfBirth = details("dogInfo")("dateOfBirth")
dogId = details("dogInfo")("dogId")
ReDim ret(1 To forms.Count, 1 To 20)
For Each form In forms
x = x + 1
ret(x, 1) = form("shortDate")
ret(x, 2) = form("trackShortName")
ret(x, 3) = form("distMetre")
ret(x, 4) = "[" & form("trapNum") & "]"
ret(x, 5) = form("secTimeS")
ret(x, 6) = form("bndPos")
ret(x, 7) = Right(form("rOutcomeDesc"), 3)
ret(x, 8) = form("rpDistDesc")
ret(x, 9) = form("otherDTxt")
ret(x, 10) = form("closeUpCmnt")
ret(x, 11) = form("winnersTimeS")
ret(x, 12) = form("goingType")
ret(x, 13) = form("weight")
ret(x, 14) = form("oddsDesc")
ret(x, 15) = form("rGradeCde")
ret(x, 16) = form("calcRTimeS")
ret(x, 17) = dogName
ret(x, 18) = trapNum
ret(x, 19) = dateOfBirth
ret(x, 20) = dogId
Next form
getDogForm = ret
End Function
Is there anything I can do to fix this please?
Many thanks.