Well...
Sometimes XML is easier... for example this json has into it more jsons...
The basic json ---> payloaddata ----> saleResponse (or abortResponse if different response), going 2 step more...
Thought was easy but when reading as map, removing quotes... then thought replaces double QUOTEs with single QUOTE... but the same...
here my code failing to do the job - i need:
I am sure if lose some hours i will find the solution... but already lost 2 days :-( and time passing !
any idea ?
thanks in advance
Sometimes XML is easier... for example this json has into it more jsons...
B4X:
{
"state": "SUCCESS",
"sessionType": "SALE",
"sessionId": "4bdebe62-c211-4ca0-a994-b2fbea2061c5",
"payloadData": {
"saleResponse": {
"transactionId": "580e0bfc-ad68-420f-af02-2900fb74496a",
"tid": "16031291",
"verificationMethod": "CONTACTLESS - NO CVM",
"retrievalReferenceNumber": 206922748800,
"transactionDate": "2022-03-11 19:34:58.0163 +02:00",
"authorizationId": "266207",
"panEntryMode": "07",
"aid": "Identifier",
"tipAmount": 50,
"amount": 1220,
"isAbortRequested": false,
"applicationLabel": "VISA Debit",
"primaryAccountNumberMasked": "479275XXXXXX9999",
"referenceNumber": 325495,
"orderCode": "2329122555031291",
"shortOrderCode": "2328182546",
"installments": 0,
"eventId": 10051,
"message": "Transaction successful",
"isSuccess": true,
"transactionTypeId": 5,
"merchantApproved": true,
"aadeTransactionId": "116123456833121690882"
}
}
}
The basic json ---> payloaddata ----> saleResponse (or abortResponse if different response), going 2 step more...
Thought was easy but when reading as map, removing quotes... then thought replaces double QUOTEs with single QUOTE... but the same...
here my code failing to do the job - i need:
B4X:
Dim jsonstring As String=j.GetString.As(String).Replace(QUOTE,"'")
Log(jsonstring)
Dim m As Map = jsonstring.As(JSON).ToMap 'ignore
state=m.Get("state")
sType=m.Get("sessionType")
Dim atext As String=m.get("payloadData").As(String)
Log("----")
Log(atext)
If atext.Trim.Length>0 And atext.trim<>"null" Then
Dim payloaddata As Map = atext.As(JSON).ToMap
Dim btext As String=payloaddata.Get("abortResponse").As(String)
If btext.Trim.Length>0 And btext.trim<>"null" Then
Dim abortresponse As Map = btext.As(JSON).ToMap
isSuccess=abortresponse.Get("isSuccess")
End If
Dim ctext As String=payloaddata.Get("saleResponse").As(String)
If ctext.Trim.Length>0 And btext.trim<>"null" Then
Dim saleresponse As Map = ctext.As(JSON).ToMap
transactionId=saleresponse.Get("transactionId")
aadeTransactionId=saleresponse.get("aadeTransactionId")
isSuccess=saleresponse.Get("isSuccess")
isAbortRequested = saleresponse.Get("isAbortRequested")
message=saleresponse.Get("message")
End If
End If
I am sure if lose some hours i will find the solution... but already lost 2 days :-( and time passing !
any idea ?
thanks in advance