I have a simple JSON array like this:
["123", "124", "321"]
The expected result should be 3
. How can I count the number of elements without using regular expressions and always working with a JSON object?
I tried using the following code:
Dim jsonStr, jsonArray, elementCount
jsonStr = "[""123"", ""124"", ""321""]"
Set jsonScriptControl = CreateObject("ScriptControl")
jsonScriptControl.Language = "JScript"
Set jsonArray = jsonScriptControl.Eval("(" + jsonStr + ")")
elementCount = jsonArray.Length
MsgBox "Number of elements: " & elementCount
However, I encountered an error message:
Microsoft VBScript runtime error: An ActiveX component cannot create an object: 'ScriptControl'.