Why is this not working with TJSONObject?
procedure TForm1.Button5Click(Sender: TObject);
var
js : TJSONObject;
isoDate1, isoDate2, data : string;
begin
isoDate1 := '2018-01-02T10:00:00.000Z';
isoDate2 := '2018-01-02T10:10:00.000Z';
js := TJSONObject.Create;
js.AddPair(TJsonPair.Create(isoDate1, 'TEST'));
js.AddPair(TJsonPair.Create(isoDate2, 'TEST2'));
outputdebugstring(pchar(js.ToString));
if js.TryGetValue<string>(isoDate1, data) then begin
ShowMessage(data);
end else begin
ShowMessage('data non trouvé pour ' + isoDate1);
end;
end;
output : Sortie de débogage: {"2018-01-02T10:00:00.000Z":"TEST","2018-01-02T10:10:00.000Z":"TEST2"} Processus Project1.exe (6232)
Expected Outcome:
The TryGetValue should put a string in data
ShowMessage should give me 'TEST' in a message box.
Outcome:
The ShowMessage give me 'data non trouvé pour 2018-01-02T10:00:00.000Z'.