TROJSONArray

Overview

The TROJSONArray class is created to represent a JSON array - an ordered collection of values. This class is used internally by the JSON (de)serializer inside the TROJSONMessage class.
Users are not required to deal with JSON directly, so they usually don't need to use this class.

Location

  • Unit: uROJSONParser.pas
  • Ancestry: TCollection | TROJSONArray

 

constructor Create

Creates the array object.

constructor Create

Add

Adds a new empty value to the array and returns the created item for further modification.

function Add: TROJSONValue

AddArrayValue

Adds a new array (TROJSONArray class) value to the array and returns the created item for further modification.

function AddArrayValue: TROJSONValue

AddBooleanValue

Adds a new boolean value to the array and returns the created item for further modification.

function AddBooleanValue(const AValue: Boolean): TROJSONValue

Parameters:

  • AValue: Boolean value to add

AddNullValue

Adds a new Null value to the array and returns the created item for further modification.

function AddNullValue: TROJSONValue

AddNumberValue

Adds a new number value to the array and returns the created item for further modification.

function AddNumberValue(const AValue: Variant): TROJSONValue

Parameters:

  • AValue: Value to add, the variant value must be convertible to a number

AddObject

Adds a new object (TROJSONObject class) value to the array and returns the created item for further modification.

function AddObject: TROJSONValue

AddStringValue

Adds a new string value to the array and returns the created item for further modification.

function AddStringValue(const AValue: JSON_String): TROJSONValue

Parameters:

  • AValue: Value to add, the variant value must be convertible to string

AddVariantValue

Adds a new variant value to the array and returns the created item for further modification.

function AddVariantValue(const AValue: Variant): TROJSONValue

Parameters:

  • AValue: Value to add

FindObjectByStringValue

Locates the JSON object item (TROJSONObject class) which contains the property named AName having the value AValue. Returns nil if the object is not found.

function FindObjectByStringValue(const AName: JSON_String; const aValue: JSON_String): TROJSONObject

Parameters:

  • AName: Name of the property
  • aValue: Value of the property

Items

Provides acceess to the array items by index.

property Items[Index: Integer]: TROJSONValue read write

LoadFromStream

Deserializes the object from the srream.

procedure LoadFromStream(AStream: TStream; AUTF8Stream: boolean)

Parameters:

  • AStream: Source stream
  • AUTF8Stream: If set to true, the stream is assumed to have UTF-8 encoded data

SaveToStream

Serializes the object to the stream.

procedure SaveToStream(AStream: TStream; AUTF8Stream: boolean)

Parameters:

  • AStream: Target stream.
  • AUTF8Stream: If set to true, the data is written using UTF-8 encoding

 

Items

Provides acceess to the array items by index.

property Items[Index: Integer]: TROJSONValue read write

 

constructor Create

Creates the array object.

constructor Create

Add

Adds a new empty value to the array and returns the created item for further modification.

function Add: TROJSONValue

AddArrayValue

Adds a new array (TROJSONArray class) value to the array and returns the created item for further modification.

function AddArrayValue: TROJSONValue

AddBooleanValue

Adds a new boolean value to the array and returns the created item for further modification.

function AddBooleanValue(const AValue: Boolean): TROJSONValue

Parameters:

  • AValue: Boolean value to add

AddNullValue

Adds a new Null value to the array and returns the created item for further modification.

function AddNullValue: TROJSONValue

AddNumberValue

Adds a new number value to the array and returns the created item for further modification.

function AddNumberValue(const AValue: Variant): TROJSONValue

Parameters:

  • AValue: Value to add, the variant value must be convertible to a number

AddObject

Adds a new object (TROJSONObject class) value to the array and returns the created item for further modification.

function AddObject: TROJSONValue

AddStringValue

Adds a new string value to the array and returns the created item for further modification.

function AddStringValue(const AValue: JSON_String): TROJSONValue

Parameters:

  • AValue: Value to add, the variant value must be convertible to string

AddVariantValue

Adds a new variant value to the array and returns the created item for further modification.

function AddVariantValue(const AValue: Variant): TROJSONValue

Parameters:

  • AValue: Value to add

FindObjectByStringValue

Locates the JSON object item (TROJSONObject class) which contains the property named AName having the value AValue. Returns nil if the object is not found.

function FindObjectByStringValue(const AName: JSON_String; const aValue: JSON_String): TROJSONObject

Parameters:

  • AName: Name of the property
  • aValue: Value of the property

LoadFromStream

Deserializes the object from the srream.

procedure LoadFromStream(AStream: TStream; AUTF8Stream: boolean)

Parameters:

  • AStream: Source stream
  • AUTF8Stream: If set to true, the stream is assumed to have UTF-8 encoded data

SaveToStream

Serializes the object to the stream.

procedure SaveToStream(AStream: TStream; AUTF8Stream: boolean)

Parameters:

  • AStream: Target stream.
  • AUTF8Stream: If set to true, the data is written using UTF-8 encoding