VBA-tools / VBA-JSON

JSON conversion and parsing for VBA
MIT License
1.76k stars 568 forks source link

Run-time error 454 Object Required and Run-time error 5 Invalid call or argument #185

Open bendavidbp opened 3 years ago

bendavidbp commented 3 years ago

When following the advanced example I receive a "Run-time error 454 Object Required" on the line highlighted in the attached image. The JSon for the sResponse that it's processing is also attached:

Run-time error 454 Object Required - Highlighted Run-time error 454 Object Required

sResponse.txt

I only started using the advanced example because I was receiving a "Run-time error 5 Invalid call or argument" when using it (attached as well). I was fairly confident I was applying the correct usage looking at the introduction docs:

Run-time error 5 Invalid call or argument - Highlighted Run-time error 5 Invalid call or argument

sResponse.txt

Any help on either of these would be greatly appreciated. Thanks!

bendavidbp commented 3 years ago

I solved the Run-time error 5 Invalid call or argument implementing a solution from another ticket, I changed the statement to the following to account for the brackets:

Debug.Print oParsedJson("Products")(1)("IngredientsStatement")(1)

This yielded the correct result. I'm still curious about the 454 error. I understand the values("a") etc. toward the bottom of that snippet wouldn't work and will need to be adjusted for the values in the JSON I'm attempting to parse, but why am I receiving this error before I even get there? Parsed("values").count is a syntax I've never seen used with dictionaries. Is the count supposed to be derived from the "values" key that the converter is presumably creating?

bendavidbp commented 3 years ago

Perhaps I'm receiving the "Run-time error 454 Object Required" error because the "values" field is in the example.json file? I need to check this out next week and see if this is the cause, thought that specific syntax does look unfamiliar to me unless the count is referencing a nested dictionary, even still I haven't seen ".Item"used for that purpose previously.