VBA-tools/VBA-JSON

Compile Error: Method or Data Member Not Found

stevenlmas opened this issue · 1 comments

Hi,

Trying to run the first example in the readme and getting a Compile Error: Method or Data Member Not Found error in json_ParseObject:

Sub Main()
Dim Json As Object
Set Json = JsonConverter.ParseJson("{""a"":123,""b"":[1,2,3,4],""c"":{""d"":456}}")
End Sub

Getting the error on the line noted below (json_ParseObject.item(json_Key)) :

 json_Key = json_ParseKey(json_String, json_Index)
          json_NextChar = json_Peek(json_String, json_Index)
           If json_NextChar = "[" Or json_NextChar = "{" Then
                Set json_ParseObject.item(json_Key) = json_ParseValue(json_String, json_Index)
         `Else
               json_ParseObject.item(json_Key) = json_ParseValue(json_String, json_Index)
          End If
   Loop

          json_Key = json_ParseKey(json_String, json_Index)
            json_NextChar = json_Peek(json_String, json_Index)
            If json_NextChar = "[" Or json_NextChar = "{" Then
----------------->Set json_ParseObject.item(json_Key) = json_ParseValue(json_String, json_Index)
            Else
                json_ParseObject.item(json_Key) = json_ParseValue(json_String, json_Index)
            End If
        Loop

I added MS Scripting Dictionary Reference in Tools > References.

What else am I missing?

Figured it out... although I had the Reference to MS Scripting in the project, I needed to add "Scripting." in the function return type.

' ============================================= '
' Private Functions
' ============================================= '

Private Function json_ParseObject(json_String As String, ByRef json_Index As Long) As Scripting.Dictionary