System.JSON.TJSONObject

Delphi
TJSONObject = class sealed(TJSONValue)
C++
class PASCALIMPLEMENTATION TJSONObject : /*[[sealed]]*/ public TJSONValue
Propriétés
Type | Visibilité | Source | Unité | Parent |
---|---|---|---|---|
class | public | System.JSON.pas System.JSON.hpp |
System.JSON | System.JSON |
Description
Implémente un objet JSON.
TJSONObject est la classe qui implémente un objet JSON.
La méthode Parse peut être utilisée pour analyser un flux de données JSON et stocker les paires JSON rencontrées dans l'instance de TJSONObject.
La méthode ParseJSONValue peut être utilisée pour analyser un tableau d'octets et créer la valeur JSON correspondante à partir de ces données.
Exemple
Voici un exemple qui explique comment analyser des données JSON en utilisant TJSONObject
program JsonTest;
{$APPTYPE CONSOLE}
uses
System.JSON;
var
S: string;
Obj: TJSONObject;
begin
S := '{"sid": "1234567890ABCDEF", "status": "queued"}';
try
Obj := TJSONValue.ParseJSONValue(S, False {UseBool}, True {RaiseException}) as TJSONObject;
try
Writeln(Obj.GetValue<string>('sid'), ' ', Obj.GetValue<string>('status'));
finally
Obj.Free;
end;
except
on E: EJSONException do
Writeln( E.Message );
end;
end.
Lorsqu'il est exécuté, voici le résultat :
1234567890ABCDEF queued