I am looping through different process ids to access the data within the json and copy it to my spreadsheet. However, some of the process id contain no data and every time my code gets to these empty arrays I get an error. I have tried different variations of if statements to skip this but still get an error. The empty array is at "expectedRateSetList"
I have tried different variations of if statements to skip this but still get an error. I've tried 'If J is null, if J is nothing, If J is empty" etc but I still can't get it to work. I've also tried "On error go to" but this hasn't worked.
`````````````
For l = 2 To last_row(tb, 2)
Set J = setJSON(url)
Set J = CallByName(J, "expectedRateSetList", VbGet) <---This is the array that is empty
If J Is Null Then GoTo next_log
On Error GoTo next_log
Set J = CallByName(J, "0", VbGet)
Set J = CallByName(J, "expectedRateList", VbGet)
next_log:
Next l
'json array looks like this:
{"processId":X,"expectedRateSetList":[],"warehouseId":"warehouseX"}
Jis an array?Setassigns object references, not arrays, andCallByNameworks with an object instance, not an array - that said0is an illegal member name, so that"0"call is guaranteed to fail. What doessetJSONactually do/return? What is the specific error you're getting exactly?Jwould be aDictionaryobject, andJ("expectedRateSetList")should get you anotherDictionary; objects are neverNullin VB, but they can beNothing- that said you shouldn't be changing the type and meaning ofJlike this. Variables are cheap - declare them with an explicit data type, and give them meaningful names!J(well the first one anyway) is aDictionary, thenIf J.Count > 0 Thenshould rid you of thatGoTojump.