如何解析 JSON 字符串
{"data":{"results":[{"Branch":"ACCT590003"}]}}
使用TJSONObject
目的?我想从此字符串中获取 ACCT590003
值。
最佳答案
您不需要使用外部库来执行 JSONPath 搜索。 以 Delphi 10 西雅图为例:
uses System.JSON;
procedure ParseJSonValue;
var
JSonValue:TJSonValue;
st:string;
Branch: string;
begin
st := '{"data":{"results":[{"Branch":"ACCT590003"}]}}';
JsonValue := TJSonObject.ParseJSONValue(st);
Branch := JsonValue.GetValue<string>('data.results[0].Branch');
JsonValue.Free;
end;
关于delphi - 如何在Delphi中解析JSON字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4350886/