Skip to content

TJSONData

Base (abstract) object for all JSON based data types.

Declaration

Source position: fpjson.pp line 126

type

  TJSONData = class(TObject)
  public
    class function JSONType : TJSONtype;
    class property CompressedJSON: Boolean; {rw}
    constructor Create;
    procedure Clear;
    procedure DumpJSON;
    function GetEnumerator : TBaseJSONEnumerator;
    function FindPath : TJSONData;
    function GetPath : TJSONData;
    function Clone : TJSONData;
    function FormatJSON : TJSONStringType;
    property Count: Integer; {r}
    property Items[Index : Integer]: TJSONData; {rw}
    property Value: TJSONVariant; {rw}
    property AsString: TJSONStringType; {rw}
    property AsUnicodeString: TJSONUnicodeStringType; {rw}
    property AsInt64: Int64; {rw}
    property AsQWord: QWord; {rw}
    property AsLargeInt: TJSONLargeInt; {rw}
    property AsFloat: TJSONFloat; {rw}
    property AsInteger: Integer; {rw}
    property AsBoolean: Boolean; {rw}
    property IsNull: Boolean; {r}
    property AsJSON: TJSONStringType; {r}
  end;

Inheritance

Description

TJSONData is an abstract class which introduces all properties and methods needed to work with JSON-based data. It should never be instantiated. Based on the type of data that must be represented one of the following descendents must be instantiated instead.

Numbers
must be represented using one of TJSONIntegerNumber, TJSONFloatNumber or TJSONInt64Number, depending on the type of the number.
Strings
can be represented with TJSONString.
Boolean
can be represented with TJSONBoolean.
null
is supported using TJSONNull
Array
data can be represented using TJSONArray
Object
data can be supported using TJSONObject

Properties

Member Visibility Description
AsBoolean public Access the raw JSON value as a boolean.
AsFloat public Access the raw JSON value as a float.
AsInt64 public Access the raw JSON value as an 64-bit integer.
AsInteger public Access the raw JSON value as an 32-bit integer.
AsJSON read only public Return a JSON representation of the value.
AsLargeInt public Access to data as largeint.
AsQWord public Access the raw JSON value as an 64-bit unsigned integer.
AsString public Access the raw JSON value as a string.
AsUnicodeString public Return the value as a Unicode string.
CompressedJSON public Compress JSON - skip whitespace.
Count read only public Number of sub-items for this data element.
IsNull read only public Is the data a null value ?
Items public Indexed access to sub-items.
Value public The value of this data object as a variant.
See all Properties

Methods

Member Visibility Description
Clear public Clear the raw value of this data object.
Clone public Duplicate the value of the JSON data.
Create public Create a new instance of TJSONData.
DumpJSON public Fast, memory efficient dump of JSON in stream.
FindPath public Find data by name.
FormatJSON public Return a formatted JSON representation of the data.
GetEnumerator public Return an enumerator for the data.
GetPath public Get data by name.
JSONType public The native JSON data type represented by this object.
See all Methods

See also

Name Description
TJSONIntegerNumber Class to represent 32-bit integer JSON data.
TJSONString Class to represent string JSON data.
TJSONBoolean Class to represent boolean JSON data.
TJSONNull Class to represent boolean JSON data.
TJSONArray Class of TJSONArray.
TJSONObject Class of TJSONObject.