I'm new to Delphi and I learn it at the moment. I have this peace of code. It works very well.
procedure TForm2.Button1Click(Sender: TObject);
var
jValue : TJSONValue;
JsonArray: TJSONArray;
begin
RESTRequest1.Execute;
jValue := RESTResponse1.JSONValue;
// Ist this the right way? --> JsonArray := TJSonObject.ParseJSONValue(jValue.ToString) as TJSONArray;
MemoContent.Lines.Add('Zitat des Tages:');
MemoContent.Lines.Add(jValue.ToString);
end;
The output is the following JSON String:
Zitat des Tages:\n
{"951":{"zitat":"\nWo ein Wille ist, ist auch ein Holzweg.\n\n","autor":"André Brie"},"timestamp":"2020 09 03 19:21:36"}
Now, I want to parse the JSON Object to write zitat, autor to my memo. But I don't know to do that. I've read a lot, but I don't understand to get my string into an array and then to parse it to the elements.
Any tipps or some help from you profies?
Thanks for help.
TRESTResponse.JSONValueis already parsed for you. You do not need to convert it to astringjust to re-parse it yourself. Change this:JsonArray := TJSonObject.ParseJSONValue(jValue.ToString) as TJSONArray;to this:JsonArray := jValue as TJSONArray;