VBA-tools/VBA-JSON

Run-time error '424' Object Required

cosmoc opened this issue · 4 comments

Executing advanced example. Run-time error '424' Issue appears on

Dim Values As Variant
ReDim Values(Parsed("values").Count, 3)

from the advanced example

The Spec.xlsx show all "pass"

Running Windows Microsoft® Excel® for Microsoft 365 MSO (Version 2302 Build 16.0.16130.20806) 64-bit

I am single-stepping in debug

I created an example.json using the same data as the first example in the Readme.md

The JSON content is
{"a":123,"b":[1,2,3,4],"c":{"d":456}}

This is Parsed prior to the ReDim statement

image

I have tried other content and encounter the same error.

NOTE: I previously erroneously reported this in the wrong Git repo.

The issue you have comes from the fact that you are using the JSON data from the first example inside the second example:

The JSON content for the second example is something like this :
{"values":[{"a":1,"b":2,"c": 3}]}

And then the Parsed variable should look something like this:
image

In this case, you can see that the key "values" that you call on the dictionary isn't a special key that returns values. For the key to be valid it has to appear as an item in the object.

Thank you. I see that data was in the comment, however, my mistake to copy the first example's json data. I think I am all set and I appreciate the help.

Thank you

My pleasure!