Loads a JSON file to the JSONParser or JSONPackage objects.

Applies to

JSONParser and JSONPackage

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 an object which contains a set of key/value pairs where key is the name of a JSONObjectItem-type object (corresponding to the data being added into the package, such as "d_department" and "d_employee_syntax") and the value for the key can be a string, object, or array in the following formats: plain JSON, or DataWindow JSON.

    Here is the structure of this JSON format:

    { "KEY1":VALUE1, "KEY2":VALUE2, "KEY3":VALUE3… }

    Here is an example of this JSON format:

    "d_department": {"department_id":1, "name":"developer"},
    "d_employee": [{"empoyee_id":1, "name":"my name1"}, {"empoyee_id":2, "name":"my name2"}],
    "d_employee_syntax": "release 17;\r\n datawindow(units=0 timer_interval=0 color=1073741824..."


objectname.LoadFile ( FileName )




The name of the JSONParser or JSONPackage object to which the JSON file will be loaded.


A string whose value is the file full name. Only the JSON or TXT file type is supported.

If the function is called by JSONParser, the file content must be JSON formatted.

If the function is called by JSONPackage, the file content must be JSON data of JsonObjectItem type.

Return value


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.


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")
	Messagebox("Error", ls_Error)
end if

See also