Private se
Private Sub Class_Initialize()
Set se = CreateObject("MSScriptControl.ScriptControl")
se.Language = "JScript"
se.AddCode "function getValue(jsonObj, valueName) { return jsonObj[valueName]; } "
se.AddCode "function enumKeys(jsonObj) { var keys = new Array(); for (var i in jsonObj) { keys.push(i); } return keys; } "
End Sub
Public Function Decode(ByVal json)
Set Decode = se.Eval("(" + CStr(json) + ")")
End Function
Public Function GetValue(ByVal jsonObj, ByVal valueName)
GetValue = se.Run("getValue", jsonObj, valueName)
End Function
Public Function GetObject(ByVal jsonObject, ByVal valueName)
Set GetObjet = se.Run("getValue", jsonObject, valueName)
End Function
Public Function EnumKeys(ByVal jsonObject)
Dim length, keys, obj, idx, key
Set obj = se.Run("enumKeys", jsonObject)
length = GetValue(obj, "length")
ReDim keys(length - 1)
idx = 0
For Each key In obj
keys(idx) = key
idx = idx + 1
Next
EnumKeys = keys
End Function