我收到了json格式的付款設備的回覆。我想訪問數組。 這裏是我的JSON響應PHP - 將JSON格式轉換爲數組
Without OrderId:-
doInBackground: {"amount":"1.00","reason":"Transaction declined by card","transactionId":"219775","transactionData":"{\"result\":\"success\",\"transactionId\":219775,\"billNumber\":\"101:879209:675466.0\",\"applicationId\":\"A0000001523010\",\"tsi\":\"E800\",\"tvr\":\"0800048000\",\"date\":\"21-06-2017\",\"currency\":\"NA\",\"tcResult\":\"0\",\"amount\":\"1.00\",\"terminalId\":\"98207200\",\"tipAmount\":\"0.00\",\"time\":\"15:41:58\",\"batchNumber\":\"1\",\"receiptLink\":\"http:\\\/\\\/test.mosambee.in\\\/ROOT1\\\/ViewReciept.do?action=mobileReceipt&txnId=219775\",\"merchantId\":\"P587956\",\"transactionStatus\":\"Declined\",\"deviceId\":1449,\"cardHolderName\":\"RK9018388863 \\\/\",\"invoiceNumber\":\"40\",\"approvalCode\":\"689653\",\"transactionMode\":\"CHIP\",\"cardType\":\"Invalid Card\",\"message\":\"Transaction declined by card\",\"transactionType\":\"Sale\",\"retrievalReferenceNumber\":\"000000219775\",\"cashBack\":\"NA\",\"cardNumber\":\"652163XXXXXX1698\",\"isSignatureRequired\":false,\"orderId\":\"101\",\"shipperId\":\"879209\"}","result":"false","reasonCode":"NA"}
我試圖JSON解碼,但它無法正常工作。它給了我空的數據。 我試過了:
$data = json_decode('Without OrderId:-
doInBackground: {"amount":"1.00","reason":"Transaction declined by card","transactionId":"219775","transactionData":"{\"result\":\"success\",\"transactionId\":219775,\"billNumber\":\"101:879209:675466.0\",\"applicationId\":\"A0000001523010\",\"tsi\":\"E800\",\"tvr\":\"0800048000\",\"date\":\"21-06-2017\",\"currency\":\"NA\",\"tcResult\":\"0\",\"amount\":\"1.00\",\"terminalId\":\"98207200\",\"tipAmount\":\"0.00\",\"time\":\"15:41:58\",\"batchNumber\":\"1\",\"receiptLink\":\"http:\\\/\\\/test.mosambee.in\\\/ROOT1\\\/ViewReciept.do?action=mobileReceipt&txnId=219775\",\"merchantId\":\"P587956\",\"transactionStatus\":\"Declined\",\"deviceId\":1449,\"cardHolderName\":\"RK9018388863 \\\/\",\"invoiceNumber\":\"40\",\"approvalCode\":\"689653\",\"transactionMode\":\"CHIP\",\"cardType\":\"Invalid Card\",\"message\":\"Transaction declined by card\",\"transactionType\":\"Sale\",\"retrievalReferenceNumber\":\"000000219775\",\"cashBack\":\"NA\",\"cardNumber\":\"652163XXXXXX1698\",\"isSignatureRequired\":false,\"orderId\":\"101\",\"shipperId\":\"879209\"}","result":"false","reasonCode":"NA"}', true);
return $data;
這給了我空數據。
是的,這不是*只是* JSON ... – deceze