DIAdem Help

Method: Deserialize for JsonParser

  • Updated2024-09-12
  • 2 minute(s) read

Method: Deserialize for JsonParser

Converts a JSON object into a Dictionary Object or a VBS Array. The items of the dictionary object can contain dictionary objects, VBS arrays, and primitive data types, such as strings, integer, double, and boolean.

Object.Deserialize(Json, Value)
ObjectJsonParser
Object with this method
JsonString
Specifies the JSON object.
ValueVariant
Receives a dictionary object or a VBS array.

The following example creates from a JSON object a dictionary object containing text, numbers, and another dictionary object. The example displays values of the dictionary object in the log area:

VBScriptPython

 

Dim oJsonParser, oVbsObject, sJsonString, sPath, oAggregates, sAvg
Set oJsonParser = CreateJsonParser() 
sJsonString = "{""path"":""task.id.592d7b9e-7816-4517-973d-ef03cc814e35"",""current"":{""timestamp"":""2018-11-27T12:33:27Z""," & _
"""value"":{""type"":1,""value"":""47""}},""aggregates"":{""count"":1,""avg"":47.0,""min"":""47"",""max"":""47""}}"
Call oJsonParser.Deserialize(sJsonString, oVbsObject)
sPath = oVbsObject.Item("path")
Set oAggregates = oVbsObject.Item("aggregates")
sAvg = oAggregates.Item("avg")
sJsonString = oJsonParser.Serialize(oVbsObject, True) ' make pretty for viewing
Call LogFileWrite(sJsonString)
Call LogFileWrite("path: " &  sPath & vbCRLF & "avg: " & sAvg)

Log in to get a better experience