DIAdem Help

Method: WriteFile for JsonParser

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

Method: WriteFile for JsonParser

Saves a text to an UTF-8 file.

Object.WriteFile(String, Filename)
ObjectJsonParser
Object with this method
StringString
Specifies the text.
FilenameString
Specifies the name and the path of the JSON file.

The following example creates a JSON object from a dictionary object containing an array and a time value in the items. The example saves the JSON object in a UTF-8 file and displays the path in the log area:

VBScriptPython

 

Dim oJsonParser, oMyMainObject, sJsonString
Set oJsonParser = CreateJsonParser()
Set oMyMainObject = CreateObject("Scripting.Dictionary")

Call oMyMainObject.Add("array", Array("TextB", 5678, True))
Call oMyMainObject.Add("timestamp", oJsonParser.CreateDateTime(Now, True))
sJsonString = oJsonParser.Serialize(oMyMainObject, True)
Call oJsonParser.WriteFile(sJsonString, DataWritePath & "JsonObject.json")
Call LogfileWrite(DataWritePath & "JsonObject.json")

Log in to get a better experience