-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTest_VbscriptJSONLib.vbs
More file actions
48 lines (38 loc) · 1 KB
/
Test_VbscriptJSONLib.vbs
File metadata and controls
48 lines (38 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
includeRelFile "./VbscriptJSONLib.vbs"
Dim data
Dim jsLib
Dim sErr
Dim jRoot
Dim jPlugin
Dim jRequire
Dim jPlugins
Call Test_ParseErrors()
Sub Test_ParseErrors()
data = createobject("Scripting.FileSystemObject").OpenTextFile("data.json", 1).ReadAll()
Set jsLib = New VbscriptJSONLib
on error resume next
Set jRoot = jsLib.parse( data )
on error goto 0
sErr = jsLib.GetParserErrors()
If sErr <> "" then
Wscript.Echo "Error while rendering the supplied Json." & vbcrlf & vbcrlf & sErr
Wscript.Quit
End If
Set jPlugin = jRoot("plugin")
Set jRequire = jPlugin("require")
Set jPlugins = jRequire("plugins")
Wscript.Echo jPlugin("id")
'Object Loop Method 1
Dim i
For i = 0 to jPlugins.count - 1
Wscript.Echo jPlugins(i)
Next
'Object Loop Method 2
Dim jPlug
For each jPlug in jPlugins
Wscript.Echo jPlug
Next
End Sub
Sub includeRelFile(fSpec)
executeGlobal CreateObject("Scripting.FileSystemObject").openTextFile(fSpec).readAll()
End Sub