Method: ReadFile for JsonParser
- Updated2024-09-12
- 1 minute(s) read
Methods > Method: ReadFile for JsonParser
Method: ReadFile for JsonParser
Reads in a string from a JSON file in UTF-8 format.
sReadFile = Object.ReadFile(Filename)
| Object | JsonParser Object with this method |
| Filename | String Specifies the name and the path of the JSON file. |
| sReadFile | String Contains a JSON string. |
The following example reads a JSON file, converts the JSON string into a dictionary object or an array, and displays the size of the dictionary object or array and the JSON string in the log area:
| VBScript | Python |
Dim oJsonParser, sFile, sJsonString, oVbsVariant Set oJsonParser = CreateJsonParser() sFile = DataWritePath & "JsonObject.json" sJsonString = oJsonParser.ReadFile(sFile) Call oJsonParser.Deserialize(sJsonString, oVbsVariant) Select Case VarType(oVbsVariant) Case vbObject Call LogfileWrite("Dictionary size: " & oVbsVariant.Count) Case vbArray + vbVariant Call LogfileWrite("Array size: " & UBound(oVbsVariant)+1) Case Else Call MsgBox("Some other data type") End Select Call LogfileWrite(sJsonString)
See Also
Related Topics
Command: ExecuteExclusiveBegin | Command: ExecuteExclusiveEnd | Command: ExecuteExclusiveEndAll