TJSONObject.Create constructor
Create a new instance of JSON object data.
Declaration
constructor Create; reintroduce
constructor Create(const Elements: Array of const); overloadArguments
Elements | Names and corresponding values to be added to the object. |
Description
Create creates a new JSON object instance, and initializes the
data with
Elements. Elements is an array containing an even
number of items, alternating a name and a value. The names must be strings,
and the values are converted to various
TJSONData instances.
If a value is an instance of
TJSONData, it is added to the object
array as-is.
The data type of the inserted objects is determined from the type of data
passed to it, with a natural mapping. A Nil pointer will be
inserted as a TJSONNull value. The following gives an example:
Var
O : TJSONObject;
begin
O:=TJSONObject.Create(['Age',44,
'Firstname','Michael',
'Lastname','Van Canneyt']);Errors
An EConvertError exception is raised in one of the following cases:
- If an odd number of arguments is passed
- an item where a name is expected does not contain a string
- A value contains an invalid class
- A value of a not recognized data type (pointer) is inserted in the elements
See also
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
