我是 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;