TJson
Class
type TJson = class
Properties
At[Index: Integer]: TJson;
Allows getting/setting an array element if it is actually a TJsonArray and the index is valid. Otherwise throws an exception.
NullAt[Index: Integer]: TJsonNull read;
FalseAt[Index: Integer]: TJsonFalse read;
TrueAt[Index: Integer]: TJsonTrue read;
ObjectAt[Index: Integer]: TJsonObject read;
StringAt[Index: Integer]: TJsonString read;
ArrayAt[Index: Integer]: TJsonArray read;
NumberAt[Index: Integer]: TJsonNumber read;
Returns the specified array element if it is actually a TJsonArray, the index is valid, and the type requested matches the contents.
Items[const Name: WideString]: TJson; default;
Allows getting/setting an object member if it is actually a TJsonObject and the member name is valid. Otherwise throws an exception.
NullItem[const Name: WideString]: TJsonNull; default;
FalseItem[const Name: WideString]: TJsonFalse; default;
TrueItem[const Name: WideString]: TJsonTrue; default;
ObjectItem[const Name: WideString]: TJsonObject; default;
StringItem[const Name: WideString]: TJsonString; default;
ArrayItem[const Name: WideString]: TJsonArray; default;
NumberItem[const Name: WideString]: TJsonNumber; default;
Returns the specified object member if it is actually a TJsonObject, the member name is valid, and the type requested matches the contents.
Methods
function AsBoolean: Boolean;
function AsDateTime: TDateTime;
function AsDateTimeOffset: Integer;
function AsNumber: Double;
function AsString: WideString;
Converts a JSON value to the appropriate type, if possible.
function IsArray: Boolean;
function IsBoolean: Boolean;
function IsDateTime: Boolean;
function IsLiteral: Boolean;
function IsNumber: Boolean;
function IsObject: Boolean;
function IsString: Boolean;
Used to test a JSON type before use the AsXYZ functions above, or creating instances of specific types.
function ToString(PrettyPrint: Boolean = True; UseTabChar: Boolean = False; TabSize: Integer = 2): WideString;
Returns a JSON string representing the JSON object. PrettyPrint uses whitespace to improve readability. UseTabChar and TabSize define formatting options.
function ToUtf8(PrettyPrint: Boolean = True; UseTabChar: Boolean = False; TabSize: Integer = 2): AnsiString;
Returns a UTF8 encoded JSON string. PrettyPrint uses whitespace to improve readability. UseTabChar and TabSize define formatting options.
function ToUtf8File(const FileName: String; PrettyPrint: Boolean = True; UseTabChar: Boolean = False; TabSize: Integer = 2);
Saves the UTF8 encoded JSON string to the specified file. PrettyPrint uses whitespace to improve readability. UseTabChar and TabSize define formatting options.
procedure Free;
Used to release memory and dispose of the object.
Example
Text |