TTMSFNCCustomDataGrid.LoadFromJSONData Method
Loads cell data from a JSON file using the specified encoding.
API unit family: TMSFNCDataGrid
Declaring type: TTMSFNCCustomDataGrid
Overloads
Overload 1
Loads cell data from a JSON file using the specified encoding.
procedure LoadFromJSONData(AFileName: string; AEncoding: TEncoding; ARowDataName: string = ''; AColumnDataName: string = ''; AColumnNames: TTMSFNCDataGridDataJSONNamesArray = nil); overload; virtual;
virtual void __fastcall LoadFromJSONData(System::UnicodeString AFileName, System::Sysutils::TEncoding* AEncoding, System::UnicodeString ARowDataName = System::UnicodeString(), System::UnicodeString AColumnDataName = System::UnicodeString(), TTMSFNCDataGridDataJSONNamesArray AColumnNames = TTMSFNCDataGridDataJSONNamesArray())/* overload */;
Remarks
Each row becomes one grid row starting at Options.IO.StartRow, each value one column starting at Options.IO.StartColumn; Options.IO.MaxRows limits the number of rows. When StartRow is greater than 0, the value names are written into row 0 as column headers.
Numbers are stored as floating-point values, true/false as Booleans and nested objects as JSON text. Each value passes through OnLoadCellData.
Parameters
| Name | Description |
|---|---|
AFileName |
Path of the JSON file. |
AEncoding |
Text encoding used to read the file. |
ARowDataName |
Name of the JSON value that holds the array of rows; ignored when the JSON root itself is an array. |
AColumnDataName |
Optional name of the value inside each row object that holds the column values; when empty or not found, the row object itself is used. |
AColumnNames |
Optional names of the row values to load, in column order; when empty, every value of a row object is loaded in its original order. |
Examples
Grid.LoadFromJSONData('orders.json', TEncoding.UTF8, 'orders', '', ['id', 'customer', 'total']);
Overload 2
Loads cell data from a JSON file using the system default (ANSI) encoding.
procedure LoadFromJSONData(AFileName: string; ARowDataName: string = ''; AColumnDataName: string = ''; AColumnNames: TTMSFNCDataGridDataJSONNamesArray = nil); overload; virtual;
virtual void __fastcall LoadFromJSONData(System::UnicodeString AFileName, System::UnicodeString ARowDataName = System::UnicodeString(), System::UnicodeString AColumnDataName = System::UnicodeString(), TTMSFNCDataGridDataJSONNamesArray AColumnNames = TTMSFNCDataGridDataJSONNamesArray())/* overload */;
Remarks
Same mapping rules as the overload with an encoding. For UTF-8 files use that overload with TEncoding.UTF8.
Parameters
| Name | Description |
|---|---|
AFileName |
Path of the JSON file. |
ARowDataName |
Name of the JSON value that holds the array of rows; ignored when the root is an array. |
AColumnDataName |
Optional name of the value inside each row object that holds the column values. |
AColumnNames |
Optional names of the row values to load, in column order. |