How to filter the 1
of "status":1
, of the text below using Delphi :
{"status":1,"data":"47281274","msg":"SUCESSO"}
I tried some StrReplace
routines, but without success!
How to filter the 1
of "status":1
, of the text below using Delphi :
{"status":1,"data":"47281274","msg":"SUCESSO"}
I tried some StrReplace
routines, but without success!
What you can use are the classes responsible for manipulating JSON in Delphi, this text that you passed is nothing more than a JavaScript Object Notation (JSON).
JSON documentation on the Embarcadero website: link
Example handling JSON:
Example that I created using the text you posted, getting the Status only and returning a ShowMessage event with the value contained in Status.
procedure showMessageWithStatus;
var
vJSONString : string;
vJSONPair : TJSONPair;
vJSONScenario: TJSONObject;
vParseResult : Integer;
vJSONScenarioEntry: TJSONValue;
vJSONScenarioValue: string;
begin
vJSONString := '{"status":1,"data":"47281274","msg":"SUCESSO"}';
try
vJSONScenario := TJSONObject.Create;
vParseResult := vJSONScenario.Parse(BytesOf(vJSONString),0);
if vParseResult >= 0 then
begin
vJSONPair := vJSONScenario.Get('status');
vJSONScenarioEntry := vJSONPair.JsonValue;
vJSONScenarioValue := vJSONScenarioEntry.Value;
ShowMessage(vJSONScenarioValue);
end;
finally
vJSONScenario.Free;
end;
end;
Any questions are available.