Sub Process_Globals
Type Point(X As Int, Y As Int)
End Sub
Sub Activity_Resume
' Point type is defined elsewhere as: Type Point(X As Int, Y As Int)
Dim poPt1 As Point
Dim poPt2 As Point
Dim poMap As Map
Dim poMap2 As Map
Dim psVal As String
Dim piVal1 As Int
Dim piVal2 As Int
poMap.Initialize
poPt1.Initialize
poPt1.X = 10
poPt1.Y = 14
'Put the key of Point struct in jSON format
poMap.Put( pointToJSONString (poPt1) , "testing 1, 2, 3")
poPt2.Initialize
poPt2.X = 10
poPt2.Y = 14
psVal = poMap.Get( pointToJSONString (poPt2) )
Log(psVal) 'outputs -> testing 1, 2, 3
piVal1 = 5
poMap2.Initialize
poMap2.Put(piVal1, "Testing 4, 5, 6")
piVal2 = 5
psVal = poMap2.Get(piVal2)
Log(psVal) 'outputs ->Testing 4, 5, 6
'************************
'Retrieve key as Custom Type Point in jSon format
Log("Key: " & poMap.GetKeyAt(0))
'Convert jSON to Point
Dim pt As Point = jSonToPoint( poMap.GetKeyAt(0) )
Log(pt.X)
Log(pt.Y)
'************************
End Sub
Sub pointToJSONString(pt As Point) As String
Return "{X:" & pt.X & ",Y:" & pt.Y & "}"
End Sub
Sub jSonToPoint(key As String) As Point
Dim JSON As JSONParser
JSON.Initialize(key)
Dim m As Map
Dim p As Point
m = JSON.NextObject
p.X=m.Get("X")
P.Y=m.Get("Y")
Return p
End Sub