I am trying to use the VBA-JSON add-in to import some JSON data from an API into a sheet. I've been able to download the module to do this but I'm unsure how to approach it. I am trying to run one of the samples provided but I keep getting an error. The module I imported is found here.
This is what I try running
Sub importjsondata()
Dim Json As Object
Set Json = JsonConverter.ParseJson("{""a"":123,""b"":[1,2,3,4],""c"":{""d"":456}}")
End Sub
It errors out on on a private function included in the downloaded module. "Compile error: User-defined type not defined"
Private Function json_ParseObject(json_String As String, ByRef json_Index As Long) As Dictionary
Could anyone help me fix this? If so, my next step would be to import the parsed data into a worksheet and I assume I would just treat the JSON object like a dictionary and loop through it.
EDIT: I found out that I just needed to add a reference to "Microsoft Scripting Runtime" and it stopped the error. Could anyone help me figure out how to loop through the dictionary and write it to a worksheet?
Bookmarks