VBA-tools / VBA-JSON

JSON conversion and parsing for VBA
MIT License
1.74k stars 566 forks source link

Compile Error: Method or Data Member Not Found #231

Closed stevenlmas closed 2 years ago

stevenlmas commented 2 years ago

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?

stevenlmas commented 2 years ago

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