Closed JoB4031 closed 6 months ago
Your text parses OK on a Windows system with VBA-Dictionary and VBA-JSON (and no Scripting Runtime).
You didn't state which text line was causing the error, although you imply it was "hasNextPage": true
. This pair is the first time a dictionary object is used. So maybe something is wrong with the Dictionary class module.
Simplify the troubleshooting with a small sub:
Sub TestDict()
Dim Dict As New Dictionary
Dict.Item("A") = 123
Debug.Print Dict.Item("A")
End Sub
Make sure you import the source code extracted from the zip packages (no direct download).
Thank you for the response. It does appear to be an issue with the Dictionary as the same error is raised with the small sub above on Dict.Item("A") = 123. It is a RunTime Error '5'. Invalid procedure call or argument.
I re-downloaded the Dictionary and imported the module. It now runs appropriately. I am not sure what I did incorrectly the first time, but thank you again.
I have been struggling to understand and debug this error. I am on an M1 Mac with macOS Ventura running Excel 16.82. I have imported both this VBA-JSON module and Dictionary/KeyVaule Pair Class modules.
When I try and ParseJson on the below text I get a run-time error in the Private Function json_ParseObject 26th line down where json_ParseObject.Item(json_Key) = json_ParseValue(json_String, json_Index) under the Else conditional. It seems to be because the json_NextChar is a true/false value that isn't bracketed by quotes. I tried to add an elsif that looked for the NextChar of "f" for false or "t" for true, but not sure what code needs to go after. I tried json_ParseObject.Item(json_Key) = True but this caused a JSON parse error 10001, expecting " or '. Thank you for correcting my confusion.
Example validated JSON is attached. JSON text.txt