uses
fphttpclient, opensslsockets, fpjson, jsonparser;
procedure TForm1.Button1Click(Sender: TObject);
var
hc: TFPHttpClient;
url: String = 'https://bcv.ingeint.com/api/bcv/rate';
json: String = '';
jd: TJsonData;
jo: TJsonObject;
begin
hc := TFPHttpClient.Create(nil);
try
json := hc.Get(url);
except
ShowMessage(Format('Error: [%d] - %s', [hc.ResponseStatusCode, hc.ResponseStatusText]));
end;
if json <> '' then
begin
jd := GetJson(json);
if jd <> nil then
begin
jo := TJsonObject(jd);
if (jo.Find('rate') <> nil) and (jo.Find('date') <> nil) then
ShowMessage(Format('Rate: %g from: %s', [jo.Find('rate').AsFloat, jo.Find('date').AsString]))
else
ShowMessage('Incorect json:'#13#10 + json);
jd.Free;
end;
end;
hc.Free;
end;