VBA-tools / VBA-JSON

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

Error 13: type mismatch #192

Closed ArmScience closed 3 years ago

ArmScience commented 3 years ago

I am trying to pass a Json object (of type "Object") to a function and access some of this Json's values from inside the function and I keep getting a type mismatch error. Any help ?

Public json As Object

Sub Main()
   'Some HTTP request logic
   Set json = JsonConverter.ParseJson(httpCall.responseText)
   someFunction json, "name", "id"
End Sub

Function someFunction(dataJson as Object, arg1 As String, arg2 As String)
    Debug.Print dataJson(1)(arg1)(arg2) 'this uses the VBA JSON library
    'As soon as I access items within dataJson, I get the type mismatch error
End Function
ArmScience commented 3 years ago

Changing the argument types to Variant fixed it.