相关疑难解决方法(0)

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

我该如何解析JSON字符串

{"data":{"results":[{"Branch":"ACCT590003"}]}}
Run Code Online (Sandbox Code Playgroud)

使用TJSONObject对象?我想ACCT590003从这个字符串中获取值.

delphi json delphi-xe

16
推荐指数
5
解决办法
4万
查看次数

从Json String Delphi XE8获取特定值

我在Delphi中有这个Json String,

{
  "bpd": {
    "euro": {
      "buying_rate": "48.50",
      "selling_rate": "52.70"
    },
    "dollar": {
      "buying_rate": "45.30",
      "selling_rate": "45.80"
    },
    "source": "https://www.popularenlinea.com/_api/web/lists/getbytitle('Rates')/items"
  },
  "blh": {
    "euro": {
      "buying_rate": "48.50",
      "selling_rate": "52.00"
    },
    "dollar": {
      "buying_rate": "45.35",
      "selling_rate": "45.80"
    },
    "source": "http://www.blh.com.do/Inicio.aspx"
  }
}
Run Code Online (Sandbox Code Playgroud)

我想为银行blh提取buy_rate和sell_rate美元

我试试这个,但我得到AV

  var
  LJsonObj  : TJSONObject;
  LRows, LElements, LItem : TJSONValue;
begin
    LJsonObj    := TJSONObject.ParseJSONValue(TEncoding.ASCII.GetBytes(s),0) as TJSONObject;
  try
     LRows:=LJsonObj.Get(0).JsonValue;
     LElements:=TJSONObject(TJSONArray(LRows).Get(0)).Get(0).JsonValue;
     LItem :=TJSONObject(TJSONArray(LElements).Get(0)).Get(0).JsonValue;
     ShowMessage(TJSONObject(LItem).Get('buying_rate').JsonValue.Value);
  finally
     LJsonObj.Free;
  end;
Run Code Online (Sandbox Code Playgroud)

delphi json delphi-xe8

2
推荐指数
1
解决办法
5604
查看次数

标签 统计

delphi ×2

json ×2

delphi-xe ×1

delphi-xe8 ×1