谷歌支付解析json令牌



当我试图解析谷歌支付令牌时,Newtonsoft.Json.dll异常中出现"Newtonsoft.Json.JsonReaderException"(示例令牌来自https://developers.google.com/pay/api/android/guides/resources/payment-data-cryptography#using-tink(

{
"protocolVersion":"ECv1",
"signature":"TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ",
"signedMessage":" {"encryptedMessage":"ZW5jcnlwdGVkTWVzc2FnZQ==",
"ephemeralPublicKey":"ZXBoZW1lcmFsUHVibGljS2V5",
"tag":"c2lnbmF0dXJl"}"
} 
using JSONObject.Parse()
after removing special characters i end up with the following 
{"protocolVersion":"ECv1",
"signature":"TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ",
"signedMessage":" 
{"encryptedMessage":"ZW5jcnlwdGVkTWVzc2FnZQ==",
"ephemeralPublicKey":"ZXBoZW1lcmFsUHVibGljS2V5","tag":"c2lnbmF0dXJl"}"}
The exception is as followed: Exception thrown: 'Newtonsoft.Json.JsonReaderException' in Newtonsoft.Json.dll
in terms of the class being used, I cannot provide the full code as it is work related, but the following is the code where JSON is used
googlePayXml = Regex.Replace(googlePayXml, "[^A-Za-z0-9+/=s]", "")
googlePayXml = Regex.Replace(googlePayXml, "\", "")
'Base64 decode Google Pay PaymentData'
Dim decodedGooglePayPaymentData As String = 
Encoding.UTF8.GetString(Convert.FromBase64String(googlePayXml))
Dim paymentData As JObject = 
JObject.Parse(decodedGooglePayPaymentData)

有人能告诉我格式有什么问题吗?

就像前面提到的see sharper一样,示例标记的格式不正确,一旦我将括号移到外面,json.parse就工作了

最新更新