Description
Loads a JSON file. The JSON file that can be loaded by the JSONPackage object must be an object (cannot be an array) and the value can be any valid string, object, or array. See JSON format for details.
Applies to
JSONParser and JSONPackage objects
Syntax
objectname.LoadFile ( FileName )
Argument |
Description |
---|---|
objectname |
The name of the JSONParser or JSONPackage object to which the JSON file will be loaded. |
FileName |
A string whose value is the file full name. Only the TXT file type is supported. The file content is the data of JsonObjectItem type. |
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:
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:
string ls_EmployeeJson, ls_Error JsonPackage lnv_package lnv_package = create JsonPackage ls_Error = lnv_package.LoadFile ("d:\temp\employees.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