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
Internal method overridden to serialize the object to the stream.
function AddBooleanValue(const aValue: Boolean): TROJSONValue
Parameters:
- aValue: Value to add, the variant value must be convertible to string
AddNullValue
Adds a new Null value to the array and returns the created item for further modification.
function AddNullValue: TROJSONValue
AddNumberValue
Internal method overridden to serialize the object to the stream.
function AddNumberValue(const aValue: Variant): TROJSONValue
Parameters:
- aValue: Value to add, the variant value must be convertible to string
AddObject
Adds a new object (TROJSONObject class) value to the array and returns the created item for further modification.
function AddObject: TROJSONValue
AddStringValue
Internal method overridden to serialize the object to the stream.
function AddStringValue(const aValue: JSON_String): TROJSONValue
Parameters:
- aValue: Value to add, the variant value must be convertible to string
AddVariantValue
Internal method overridden to serialize the object to the stream.
function AddVariantValue(const aValue: Variant): TROJSONValue
Parameters:
- aValue: Value to add, the variant value must be convertible to string
AsJSON
Returns object as JSON string
property AsJSON: JSON_String read
FindObjectByStringValue
Internal method overridden to serialize the object to the stream.
function FindObjectByStringValue(const aName: JSON_String; const aValue: JSON_String): TROJSONObject
Parameters:
- aName: Target stream.
- aValue: If set to true, the data is written using UTF-8 encoding
IntLoadFromStream protected
Internal method overridden to deserialize the object from the stream.
procedure IntLoadFromStream(Source: TStream)
Parameters:
- Source: Value to add, the variant value must be convertible to string
Items
Provides acceess to the array items by index.
property Items[Index: Integer]: TROJSONValue read write
LoadFromStream
Internal method overridden to deserialize the object from the stream.
procedure LoadFromStream(Source: TStream; aUTF8Stream: Boolean)
Parameters:
- Source: Source stream
- aUTF8Stream: If set to true, the stream is assumed to have UTF-8 encoded data
SaveToStream
Saves object to stream
procedure SaveToStream(Dest: TStream; aUTF8Stream: Boolean)
Parameters:
- Dest: Destination
- aUTF8Stream: Should be UTF-8 encoding used or not
SaveToStreamWithIndent
Saves object to stream with indent
procedure SaveToStreamWithIndent(Dest: TStream; aUTF8Stream: Boolean)
Parameters:
- Dest: Dest stream
- aUTF8Stream: Should be UTF-8 encoding used or not
AsJSON
Returns object as JSON string
property AsJSON: JSON_String read
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
Internal method overridden to serialize the object to the stream.
function AddBooleanValue(const aValue: Boolean): TROJSONValue
Parameters:
- aValue: Value to add, the variant value must be convertible to string
AddNullValue
Adds a new Null value to the array and returns the created item for further modification.
function AddNullValue: TROJSONValue
AddNumberValue
Internal method overridden to serialize the object to the stream.
function AddNumberValue(const aValue: Variant): TROJSONValue
Parameters:
- aValue: Value to add, the variant value must be convertible to string
AddObject
Adds a new object (TROJSONObject class) value to the array and returns the created item for further modification.
function AddObject: TROJSONValue
AddStringValue
Internal method overridden to serialize the object to the stream.
function AddStringValue(const aValue: JSON_String): TROJSONValue
Parameters:
- aValue: Value to add, the variant value must be convertible to string
AddVariantValue
Internal method overridden to serialize the object to the stream.
function AddVariantValue(const aValue: Variant): TROJSONValue
Parameters:
- aValue: Value to add, the variant value must be convertible to string
FindObjectByStringValue
Internal method overridden to serialize the object to the stream.
function FindObjectByStringValue(const aName: JSON_String; const aValue: JSON_String): TROJSONObject
Parameters:
- aName: Target stream.
- aValue: If set to true, the data is written using UTF-8 encoding
IntLoadFromStream protected
Internal method overridden to deserialize the object from the stream.
procedure IntLoadFromStream(Source: TStream)
Parameters:
- Source: Value to add, the variant value must be convertible to string
LoadFromStream
Internal method overridden to deserialize the object from the stream.
procedure LoadFromStream(Source: TStream; aUTF8Stream: Boolean)
Parameters:
- Source: Source stream
- aUTF8Stream: If set to true, the stream is assumed to have UTF-8 encoded data
SaveToStream
Saves object to stream
procedure SaveToStream(Dest: TStream; aUTF8Stream: Boolean)
Parameters:
- Dest: Destination
- aUTF8Stream: Should be UTF-8 encoding used or not
SaveToStreamWithIndent
Saves object to stream with indent
procedure SaveToStreamWithIndent(Dest: TStream; aUTF8Stream: Boolean)
Parameters:
- Dest: Dest stream
- aUTF8Stream: Should be UTF-8 encoding used or not