- Code: Select all Expand view RUN
- cRetData := {"transactionResponse":{"accountCardType":"VS","accountEntryMethod":"PinpadKeyed","accountExpiryDate":"XXXX","amount":"1.55","amountBalance":"","amountProcessed":"1.55","amountTaxed":"0.00","amountTipped":"0.00","approvalNumberResult":"OK6875","avsResponseCode":"","avsResponseText":"","batchNumber":"0","billingName":"","cashier":"","createdOn":"2023-02-15T00:04:35.813Z","customerId":"","cvvResponseCode":"","cvvResponseText":"","externalTransactionId":"f0270891-08da-4b1b-9a7d-5863f490b7d9","isPartialApproval":false,"maskedAccount":"************9016","resultMessage":"Approved","resultStatus":"true","transactionReference":"","transactionType":"CreditSale","uniqueTransId":"f1766ec228104c71a55ce0cd84ddaf72-00000000000000000000000000000000"}}
With other web responses I Decode the result ( into a hash ), and then use HB_HGET( ) to obtain the results.
- Code: Select all Expand view RUN
// Obtain and save the results -or- Parse the results by line
hb_JsonDecode( cRetData, @hChgData )
XBROWSER HASHTREE( hChgData, 0 ) TITLE "Hash as Tree"
// Parse the results
cTermID := HB_HGET( hChgData, "cashier") // Terminal ID
cRefCode := HB_HGET( hChgData, "maskedAccount") // Credit card number
fccddat := HB_HGET( hChgData, "createdOn") // Transaction date full string 2016-08-25T15:28:11-05:00 C 8
The browser works fine. However I need the data in that 2nd element of the array to be in the hash table ( "cashier" ) and it doesn't find it in the array because the first element ( apparently ) "transactionResponse" is what is being hashed by JsonDecode.
I'm sure there is a solution ... probably a simple modification.
Thanks.