Classe TJSONObject

Unit

Declaração

type TJSONObject = class(TZAbstractObject)

Descrição

Classe que representa um objeto JSON

Hierarquia

Visão Geral

Métodos

Public constructor create; overload;
Public constructor create(jo : TJSONObject; sa : array of string); overload;
Public constructor create(x : JSONTokener); overload;
Public constructor create(map : TStringList); overload;
Public constructor create(s : string); overload;
Public procedure clean;
Public function clone: TZAbstractObject; override;
Public function accumulate(key : string; value : TZAbstractObject) : TJSONObject;
Public function get(key : string) : TZAbstractObject;
Public function getBoolean(key : string) : Boolean;
Public function getDouble(key : string) : Double;
Public function getInt(key : string) : Integer;
Public function getInt64(key : string) : Int64;
Public function getJSONArray(key : string) : TJSONArray;
Public function getJSONObject(key : string) : TJSONObject;
Public function getString(key : string) : String;
Public function has(key : string) : Boolean;
Public function isNull(key : string) : Boolean;
Public function keys: TStringList;
Public function length: integer;
Public function names: TJSONArray;
Public class function numberToString(n: _Number): string;
Public class function valueToString(value : TZAbstractObject) : string; overload;
Public class function valueToString(value : TZAbstractObject; indentFactor , indent : integer) : string; overload;
Public function opt(key : string) : TZAbstractObject;
Public function optBoolean(key : string): boolean; overload;
Public function optBoolean(key : string; defaultValue : boolean): boolean; overload;
Public function optDouble(key : string): double; overload;
Public function optDouble(key : string; defaultValue : double): double; overload;
Public function optInt(key : string): integer; overload;
Public function optInt(key : string; defaultValue : integer): integer; overload;
Public function optInt64(key : string): Int64; overload;
Public function optInt64(key : string; defaultValue : Int64): Int64; overload;
Public function optString(key : string): string; overload;
Public function optString(key : string; defaultValue : string): string; overload;
Public function optJSONArray(key : string): TJSONArray; overload;
Public function optJSONObject(key : string): TJSONObject; overload;
Public function put(key : string; value : boolean): TJSONObject; overload;
Public function put(key : string; value : double): TJSONObject; overload;
Public function put(key : string; value : integer): TJSONObject; overload;
Public function put(key : string; value : Int64): TJSONObject; overload;
Public function put(key : string; value : string): TJSONObject; overload;
Public function put(key : string; value : TZAbstractObject): TJSONObject; overload;
Public function putOpt(key : string; value : TZAbstractObject): TJSONObject;
Public class function quote(s : string): string;
Public class function convertUTF8String(s: string): string;
Public function remove(key : string): TZAbstractObject;
Public procedure assignTo(json: TJSONObject);
Public function toJSONArray(anames : TJSONArray) : TJSONArray;
Public function toString(): string ; overload; override;
Public function toString(indentFactor : integer): string; overload;
Public function toString(indentFactor, indent : integer): string; overload;
Public destructor destroy; override;
Public class function NULL: NULL;

Descrição

Métodos

Public constructor create; overload;

* Construct an empty TJSONObject.

Public constructor create(jo : TJSONObject; sa : array of string); overload;

* Construct a TJSONObject from a subset of another TJSONObject. An array of strings is used to identify the keys that should be copied. Missing keys are ignored. .

Parâmetros
jo
A TJSONObject.
sa
An array of strings
Public constructor create(x : JSONTokener); overload;

* Construct a TJSONObject from a JSONTokener.

Parâmetros
x
A JSONTokener object containing the source string.
Exceções levantadas
ParseException
if there is a syntax error in the source string.
Public constructor create(map : TStringList); overload;

* Construct a TJSONObject from a TStringList.

Parâmetros
map
A map object that can be used to initialize the contents of the TJSONObject.
Public constructor create(s : string); overload;

* Construct a TJSONObject from a string. This is the most commonly used TJSONObject constructor.

Parâmetros
s
A string beginning with { (left brace) and ending with } (right brace).
Exceções levantadas
ParseException
The string must be properly formatted.
Public procedure clean;

* remove todos os menbros de um objeto JSON .

Public function clone: TZAbstractObject; override;

* sobreescreve o metodo clone de TZAbstractObject

Public function accumulate(key : string; value : TZAbstractObject) : TJSONObject;
 
Public function get(key : string) : TZAbstractObject;
 
Public function getBoolean(key : string) : Boolean;
 
Public function getDouble(key : string) : Double;
 
Public function getInt(key : string) : Integer;
 
Public function getInt64(key : string) : Int64;
 
Public function getJSONArray(key : string) : TJSONArray;
 
Public function getJSONObject(key : string) : TJSONObject;
 
Public function getString(key : string) : String;
 
Public function has(key : string) : Boolean;
 
Public function isNull(key : string) : Boolean;
 
Public function keys: TStringList;

* retorna um TStringList com todos os nomes dos atributos do TJSONObject

Public function length: integer;

* Retorna quantos atributos tem o TJSONObject

Public function names: TJSONArray;

* Produce a TJSONArray containing the names of the elements of this TJSONObject. .

Retorno

A TJSONArray containing the key strings, or null if the TJSONObject is empty

Public class function numberToString(n: _Number): string;

* transforma uma class wrapper _Number (Number em java) em AnsiString

Public class function valueToString(value : TZAbstractObject) : string; overload;

* Make JSON string of an object value.

Warning: This method assumes that the data structure is acyclical.

Parâmetros
value
The value to be serialized.
Retorno

a printable, displayable, transmittable representation of the object, beginning with { (left brace) and ending with } (right brace).

Public class function valueToString(value : TZAbstractObject; indentFactor , indent : integer) : string; overload;

* Make a prettyprinted JSON text of an object value.

Warning: This method assumes that the data structure is acyclical.

Parâmetros
value
The value to be serialized.
indentFactor
The number of spaces to add to each level of indentation.
indent
The indentation of the top level.
Retorno

a printable, displayable, transmittable representation of the object, beginning with { (left brace) and ending with } (right brace).

Public function opt(key : string) : TZAbstractObject;

* Get an optional value associated with a key.

Parâmetros
key
A key string.
Retorno

An object which is the value, or null if there is no value.

Exceções levantadas
NullPointerException
caso key = ''
Public function optBoolean(key : string): boolean; overload;
 
Public function optBoolean(key : string; defaultValue : boolean): boolean; overload;
 
Public function optDouble(key : string): double; overload;
 
Public function optDouble(key : string; defaultValue : double): double; overload;
 
Public function optInt(key : string): integer; overload;
 
Public function optInt(key : string; defaultValue : integer): integer; overload;
 
Public function optInt64(key : string): Int64; overload;
 
Public function optInt64(key : string; defaultValue : Int64): Int64; overload;
 
Public function optString(key : string): string; overload;
 
Public function optString(key : string; defaultValue : string): string; overload;
 
Public function optJSONArray(key : string): TJSONArray; overload;
 
Public function optJSONObject(key : string): TJSONObject; overload;
 
Public function put(key : string; value : boolean): TJSONObject; overload;
 
Public function put(key : string; value : double): TJSONObject; overload;
 
Public function put(key : string; value : integer): TJSONObject; overload;
 
Public function put(key : string; value : Int64): TJSONObject; overload;
 
Public function put(key : string; value : string): TJSONObject; overload;
 
Public function put(key : string; value : TZAbstractObject): TJSONObject; overload;

* Put a key/value pair in the TJSONObject. If the value is null, then the key will be removed from the TJSONObject if it is present.

Parâmetros
key
A key string.
value
An object which is the value. It should be of one of these types: Boolean, Double, Integer, TJSONArray, TJSONObject, String, or the TJSONObject.NULL object.
Retorno

this.

Exceções levantadas
NullPointerException
The key must be non-null.
Public function putOpt(key : string; value : TZAbstractObject): TJSONObject;

* Put a key/value pair in the TJSONObject, but only if the value is non-null.

Parâmetros
key
A key string.
value
An object which is the value. It should be of one of these types: Boolean, Double, Integer, TJSONArray, TJSONObject, String, or the TJSONObject.NULL object.
Retorno

this.

Exceções levantadas
NullPointerException
The key must be non-null.
Public class function quote(s : string): string;
 
Public class function convertUTF8String(s: string): string;
 
Public function remove(key : string): TZAbstractObject;
 
Public procedure assignTo(json: TJSONObject);
 
Public function toJSONArray(anames : TJSONArray) : TJSONArray;
 
Public function toString(): string ; overload; override;
 
Public function toString(indentFactor : integer): string; overload;
 
Public function toString(indentFactor, indent : integer): string; overload;
 
Public destructor destroy; override;
 
Public class function NULL: NULL;
 

Gerado por PasDoc 0.16.0.