Skip to content

Operation in VBA code throws type 13 mismatch error - entering it in direct window does not. #71

Open
@vinkbram

Description

@vinkbram

I am running into a problem I have no idea how to tackle, and the solutions provided otherwise in the issues do not seem to help with this problem. The debug.print line throws a type 13 Mismatch error - however if I just enter Print Parsed(1)("Description")(1)("nl_NL") in the direct window, it returns the expected value. Any other operations in the code also result in this error.

Sub Example()
Dim FSO As New FileSystemObject
Dim TS As TextStream
Dim Json As String
Dim Parsed As Variant

Set TS = FSO.OpenTextFile("C:\Example.txt")
Json = TS.ReadAll
TS.Close

Set Parsed = JsonConverter.ParseJson(Json)

Debug.Print Parsed(1)("Description")(1)("nl_NL")
End Sub

My JSON looks like this:

[ {
  "Description" : [ {
    "en_US" : null,
    "nl_BE" : "Text in dutch",
    "fr_BE" : null,
    "fr_LU" : null,
    "nl_NL" : "Text in dutch",
    "fr_FR" : null,
    "de_DE" : null
  } ],
  "Amount" : 3.3,
  "Code" : "1"
}, {
  "Description" : [ {
    "en_US" : null,
    "nl_BE" : "Geen",
    "fr_BE" : null,
    "fr_LU" : null,
    "nl_NL" : "Geen",
    "fr_FR" : null,
    "de_DE" : null
  } ],
  "Amount" : 0.0,
  "Code" : "99"
} ]

Any help would be much appreciated!
Best regards,

Bram

Example.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions