delphi 解析json java_使用SuperObject Delphi解析Json

我是JSON的新手 . 我有以下JSON数据,我不知道如何读取 transaction 对象的 id 和 amount 值 .

{

"errorCode": 0,

"errorMessage": "ok",

"platform": 4,

"order": {

"id": "3425",

"description": "test api",

"amount": 1.39,

"currency": "RON",

"billing": {

"country": null,

"county": null,

"city": null,

"address": "address",

"postal_code": null,

"first_name": "fn",

"last_name": "ln",

"phone": "0000000000",

"email": "me@mobilpay.com"

},

"shipping": null,

"installments": null,

"installments_sel": null,

"bonuspoints": null,

"products": {

"item": {

"id": null,

"name": null,

"description": null,

"info": null,

"group": null,

"amount": null,

"currency": null,

"quantity": null,

"vat": null

}

},

"hash": "1BB262DEE09B15ED98B777A27740E16B1F00004E",

"transaction": {

"id": "461512",

"amount": 1.39,

"currency": "RON",

"paymentUrl": "/qp/BdKQsV1d-DsGz0e-4Bkq2e",

"current_payment_count": null

},

"params": null

}

我可以阅读 errorCode 和 errorMessage ,但我不知道如何访问事务 id .

这是我到目前为止的代码:

function TuDm_Athlos.ReadJson(ContentStr: TStream; var Order: TOrder): Boolean;

var

workJson : ISuperObject;

begin

Result := False;

workJson := TSuperObject.ParseStream(ContentStr,False);

Order.ErrorCode := StrToInt(workJson.S['errorCode']);

order.ErrorMessage := workJson.S['errorMessage'];

for workJson in workJson.O['transaction'] do

begin

Order.id := workJson.S['id'];

end;

Result := True;

end;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值