delphi - 如何在Delphi中解析JSON字符串?

标签 delphi json delphi-xe

如何解析 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/

相关文章:

delphi - TValue 字符串<--> bool 值来回

delphi - 有没有办法在 Delphi Firemonkey 中禁用 TWebBrowser 的右键单击

delphi - 如何在delphi中创建侧边栏表单

javascript - 使用 C# 将 JSON 代码导入 Javascript 文件

json - Swift 4 没有正确解码 JSON 可选

Delphi - 在 dataset.enablecontrols 上的 TDBGrid 内部触发什么事件

Delphi - 从 TImageList 获取位图

delphi - 向 TList 和 TStringList 添加稳定排序的简单方法

delphi - 我的应用程序的表单如何使用不同的 Vcl 样式?

javascript - 从 JSON 数据生成 HTML 树