Einzelnen Beitrag anzeigen

fabi17

Registriert seit: 1. Mai 2017
44 Beiträge
 
Delphi 10.2 Tokyo Enterprise
 
#4

AW: einfaches JSON Beispiel

  Alt 16. Mär 2022, 10:39
Alternative:

Delphi-Quellcode:
program Project1;

{$R *.res}

uses System.SysUtils, System.JSON;

const
   input = '{"status":"success","data":{"status":"online","benchmarking":"TEST","online":"connected"}}';
var
   jsonObj: TJsonObject;
   status: String;
begin
   jsonObj := TJSONObject.ParseJSONValue(input) as TJsonObject;
   if(not Assigned(jsonObj)) then
      WriteLn('input is no valid json object')
   else
      try
         status := jsonObj.GetValue<String>('data.status');
         WriteLn('status is ', status);
      finally
         jsonObj.Destroy();
      end;
end.

ahhh, das "data.status" hatte ich nicht so....


Danke an beide! So langsam begreife ich es mal...
  Mit Zitat antworten Zitat