-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestRoutines
More file actions
63 lines (58 loc) · 2.35 KB
/
TestRoutines
File metadata and controls
63 lines (58 loc) · 2.35 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
Sub testParseJSON()
Dim oThing As Object
'Set oThing = parseJSON("C:\Users\Mark\Downloads\Small-REST-Output.txt")
'Set oThing = parseJSON("C:\Users\Mark\Downloads\Q_28906582.txt")
Set oThing = parseJSONfile("C:\Users\Mark\Downloads\Q_28918483.JSON.txt")
'Note: DataSave does not currently serialize object data types
' DataSave oThing(1)
testIterateObject oThing, 0
End Sub
Function testIterateObject(parmObject As Object, parmDepth As Long)
Dim vItem As Variant
Dim oItem As Object
Dim strDelim As String
Select Case TypeName(parmObject)
Case "Dictionary"
For Each vItem In parmObject
If VarType(parmObject(vItem)) = vbObject Then
Debug.Print String(parmDepth, vbTab); vItem, "Count: " & parmObject(vItem).Count
testIterateObject parmObject(vItem), parmDepth + 1
Else
Select Case VarType(parmObject(vItem))
Case VbVarType.vbString
strDelim = """"
Case VbVarType.vbDate
strDelim = "#"
Case Else
strDelim = vbNullString
End Select
Debug.Print String(parmDepth, vbTab); vItem, strDelim & parmObject(vItem) & strDelim
End If
Next
Case "Collection"
For Each vItem In parmObject
If VarType(vItem) = vbObject Then
'Debug.Print vItem
Set oItem = vItem
testIterateObject oItem, parmDepth + 1
Else
Select Case VarType(vItem)
Case VbVarType.vbString
strDelim = """"
Case VbVarType.vbDate
strDelim = "#"
Case Else
strDelim = vbNullString
End Select
Debug.Print String(parmDepth, vbTab); strDelim & vItem & strDelim
End If
Next
End Select
End Function
Sub DataSave(parmObject As Object)
'To Do: correctly persist the parsed object data in a friendly format
'Solution paths:
' * intrinsic VB I/O
' * ADODB recordset and stream
' * XML - seems like a cheat
End Sub