TROJSONProperty
Overview
The TROJSONProperty class represents a JSON named value i.e. a name-value pair. It is implemented as a value class (TROJSONValue) extension, see the ancestor's documentation for more information.
Users are not required to deal with JSON directly, so they usually don't need to use this class.
Location
- Unit: uROJSONParser.pas
- Ancestry: TCollectionItem | TROJSONValue | TROJSONProperty
constructor Create (TROJSONDataType) reintroduce overload (declared in TROJSONValue)
Creates a new object instance and specifies the data type to store in it.
constructor Create(aType: TROJSONDataType)
Parameters:
- aType: Data type to store (TROJSONDataType value).
constructor Create (TCollection) overload override (declared in TROJSONValue)
Creates a new object instance and specifies the owning collection for it.
constructor Create(Collection: TCollection)
Parameters:
- Collection: Collection that owns this item, should be a TROJSONObject or TROJSONArray instance.
AsArray (declared in TROJSONValue)
Reads and writes the value as JSON array.
property AsArray: TROJSONArray read write
AsBoolean (declared in TROJSONValue)
Reads and writes the value as boolean.
property AsBoolean: Boolean read write
AsJSON (declared in TROJSONValue)
Returns object as JSON string
property AsJSON: JSON_String read
AsNumber (declared in TROJSONValue)
Reads and writes the value as number. The Variant data type is used to store the number.
property AsNumber: Variant read write
AsObject (declared in TROJSONValue)
Reads and writes the value as a JSON object.
property AsObject: TROJSONObject read write
AsString (declared in TROJSONValue)
Reads and writes the value as string.
property AsString: JSON_String read write
Clear (declared in TROJSONValue)
Empties the object. It will contain the value equivalent to NULL after this call.
procedure Clear
IntLoadFromStream protected override
This method is overridden to support the Name deserialization.
procedure IntLoadFromStream(Source: TStream)
Parameters:
- Source: Source stream to deserialize from
IsArray (declared in TROJSONValue)
Checks if value is embedded array
function IsArray: Boolean
IsBoolean (declared in TROJSONValue)
function IsBoolean: Boolean
IsNull (declared in TROJSONValue)
Checks if value is Null
function IsNull: Boolean
IsNumber (declared in TROJSONValue)
function IsNumber: Boolean
IsObject (declared in TROJSONValue)
function IsObject: Boolean
IsString (declared in TROJSONValue)
function IsString: Boolean
LoadFromStream (declared in TROJSONValue)
This internal method may be overriden in descendants to implement a specific object deserialization from the stream. Called by the LoadFromStream method.
procedure LoadFromStream(Source: TStream; aUTF8Stream: Boolean)
Parameters:
- Source: Source stream
- aUTF8Stream: When set to true, the object will use UTF-8 encoding when deserializing the data.
LoadValueFromStream
Loads object from stream
procedure LoadValueFromStream(Source: TStream; aUTF8Stream: Boolean)
Parameters:
- Source:
- aUTF8Stream:
Name
Stores the name part of the name-value pair.
property Name: JSON_String read write
SaveToStream (declared in TROJSONValue)
Saves object to stream
procedure SaveToStream(Dest: TStream; aUTF8Stream: Boolean)
Parameters:
- Dest: Dest stream
- aUTF8Stream: Should be UTF-8 encoding used or not
SaveToStreamWithIndent (declared in TROJSONValue)
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
SaveValueToStream
Saves object to stream
procedure SaveValueToStream(Dest: TStream; aUTF8Stream: Boolean)
Parameters:
- Dest:
- aUTF8Stream:
SetAsNull (declared in TROJSONValue)
Sets the NULL value to the object, this is equivalent to the Clear call.
procedure SetAsNull
ValueType (declared in TROJSONValue)
Allows to get the data type (TROJSONDataType value) that is currently stored in the object.
property ValueType: TROJSONDataType read
VarValue (declared in TROJSONValue)
Reads and writes the value as a Variant.
property VarValue: Variant read write
AsArray (declared in TROJSONValue)
Reads and writes the value as JSON array.
property AsArray: TROJSONArray read write
AsBoolean (declared in TROJSONValue)
Reads and writes the value as boolean.
property AsBoolean: Boolean read write
AsJSON (declared in TROJSONValue)
Returns object as JSON string
property AsJSON: JSON_String read
AsNumber (declared in TROJSONValue)
Reads and writes the value as number. The Variant data type is used to store the number.
property AsNumber: Variant read write
AsObject (declared in TROJSONValue)
Reads and writes the value as a JSON object.
property AsObject: TROJSONObject read write
AsString (declared in TROJSONValue)
Reads and writes the value as string.
property AsString: JSON_String read write
Name
Stores the name part of the name-value pair.
property Name: JSON_String read write
ValueType (declared in TROJSONValue)
Allows to get the data type (TROJSONDataType value) that is currently stored in the object.
property ValueType: TROJSONDataType read
VarValue (declared in TROJSONValue)
Reads and writes the value as a Variant.
property VarValue: Variant read write
constructor Create (TROJSONDataType) reintroduce overload (declared in TROJSONValue)
Creates a new object instance and specifies the data type to store in it.
constructor Create(aType: TROJSONDataType)
Parameters:
- aType: Data type to store (TROJSONDataType value).
constructor Create (TCollection) overload override (declared in TROJSONValue)
Creates a new object instance and specifies the owning collection for it.
constructor Create(Collection: TCollection)
Parameters:
- Collection: Collection that owns this item, should be a TROJSONObject or TROJSONArray instance.
Clear (declared in TROJSONValue)
Empties the object. It will contain the value equivalent to NULL after this call.
procedure Clear
IntLoadFromStream protected override
This method is overridden to support the Name deserialization.
procedure IntLoadFromStream(Source: TStream)
Parameters:
- Source: Source stream to deserialize from
IsArray (declared in TROJSONValue)
Checks if value is embedded array
function IsArray: Boolean
IsBoolean (declared in TROJSONValue)
function IsBoolean: Boolean
IsNull (declared in TROJSONValue)
Checks if value is Null
function IsNull: Boolean
IsNumber (declared in TROJSONValue)
function IsNumber: Boolean
IsObject (declared in TROJSONValue)
function IsObject: Boolean
IsString (declared in TROJSONValue)
function IsString: Boolean
LoadFromStream (declared in TROJSONValue)
This internal method may be overriden in descendants to implement a specific object deserialization from the stream. Called by the LoadFromStream method.
procedure LoadFromStream(Source: TStream; aUTF8Stream: Boolean)
Parameters:
- Source: Source stream
- aUTF8Stream: When set to true, the object will use UTF-8 encoding when deserializing the data.
LoadValueFromStream
Loads object from stream
procedure LoadValueFromStream(Source: TStream; aUTF8Stream: Boolean)
Parameters:
- Source:
- aUTF8Stream:
SaveToStream (declared in TROJSONValue)
Saves object to stream
procedure SaveToStream(Dest: TStream; aUTF8Stream: Boolean)
Parameters:
- Dest: Dest stream
- aUTF8Stream: Should be UTF-8 encoding used or not
SaveToStreamWithIndent (declared in TROJSONValue)
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
SaveValueToStream
Saves object to stream
procedure SaveValueToStream(Dest: TStream; aUTF8Stream: Boolean)
Parameters:
- Dest:
- aUTF8Stream:
SetAsNull (declared in TROJSONValue)
Sets the NULL value to the object, this is equivalent to the Clear call.
procedure SetAsNull