LoadFile
PowerScript function
Description
Loads a JSON file.
Required JSON format
-
For JSONParser object: The file content that can be loaded by
the JSONParser object must be JSON-formatted. -
For JSONPackage object: The file content that can be loaded by
the JSONPackage object must be of JSONObjectItem type (cannot be an
array) and the values for the keys in the JSON can be any valid
string, object, or array. For details, see JSON formats (required by
JSONPackage object).
Applies to
JSONParser and JSONPackage objects
Syntax
|
1 |
objectname.LoadFile ( FileName ) |
|
Argument |
Description |
|---|---|
|
objectname |
The name of the JSONParser or JSONPackage object to |
|
FileName |
A string whose value is the file full name. Only the If the function is If the function is called by JSONPackage, |
Return value
String.
Returns the empty string (“”) if it succeeds and the error message
if an error occurs. If any argument’s value is null, the method returns
null.
Examples
This example loads a JSON file into the JSONParser object:
|
1 2 3 4 5 6 7 8 |
String ls_Error JsonParser lnv_JsonParser lnv_JsonParser = Create JsonParser ls_Error = lnv_JsonParser.LoadFile("c:employee.json") if Len(ls_Error) > 0 then MessageBox("Error", ls_Error) end if |
This example loads data from the employees.txt file and then loads
the “d_employee” data into the DataWindow:
|
1 2 3 4 5 6 7 8 9 10 11 12 |
string ls_EmployeeJson, ls_Error JsonPackage lnv_package lnv_package = create JsonPackage ls_Error = lnv_package.LoadFile ("d: empemployees.txt") if Len(ls_Error) = 0 then ls_EmployeeJson = lnv_package.GetValue("d_employee") dw_1.ImportJson(ls_EmployeeJson) else Messagebox("Error", ls_Error) end if |
See also