第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

無法將 json 字符串反序列化為 ac# 類

無法將 json 字符串反序列化為 ac# 類

C#
回首憶惘然 2022-12-31 13:40:40
我有一個(gè)從 api 端點(diǎn)返回的 json 字符串,我正在嘗試將其反序列化為 ac# 類。反序列化過程出錯(cuò)。傳入的json字符串:{"amount":"3.00","resptext":"Approval","cvvresp":"P","respcode":"000","avsresp":"","merchid":"800000000800","token":"9478837814450119","authcode":"PPS306","respproc":"RPCT","emvTagData":"{\"TVR\":\"0200008000\",\"PIN\":\"None\",\"Signature\":\"true\",\"Mode\":\"Issuer\",\"ARC\":\"Z3\",\"TSI\":\"E800\",\"Application Preferred Name\":\"CREDITO DE VISA\",\"AID\":\"A0000000031010\",\"IAD\":\"06010A03A00000\",\"Entry method\":\"Chip Read\",\"Application Label\":\"VISA CREDIT\"}","retref":"116390139157","respstat":"A","account":"47XXXXXXXXXX0119"}C#類:public class AuthCardResponse    {              public string token { get; set; }        public string expiry { get; set; }        public string name { get; set; }        public string batchid { get; set; }        public string retref { get; set; }        public string avsresp { get; set; }        public string respproc { get; set; }        public string amount { get; set; }        public string resptext { get; set; }        public string authcode { get; set; }        public string respcode { get; set; }        public string merchid { get; set; }        public string cvvresp { get; set; }        public string respstat { get; set; }        public string account { get; set; }        public string bintype { get; set; }        public string entrymode{get;set;}        public string commcard { get; set; }                //public string emvTagData { get; set; }                public EmvTagData emvTagData { get; set; }    }        public class EmvTagData    {        public string TVR { get; set; }        public string PIN { get; set; }        public string Signature { get; set; }        public string Mode { get; set; }        public string TSI { get; set; }        public string AID { get; set; }        public string ARC { get; set; }        public string IAD { get; set; }    }}
查看完整描述

3 回答

?
撒科打諢

TA貢獻(xiàn)1934條經(jīng)驗(yàn) 獲得超2個(gè)贊

您的 emvTagData 是一個(gè)文字字符串,但您正試圖將其反序列化為一個(gè)復(fù)雜的對(duì)象。

"emvTagData":"{\"TVR\":\"0200008000\",\"PIN\":\"None\",\"Signature\":\"true\",\"Mode\":\"Issuer\",\"ARC\":\"Z3\",\"TSI\":\"E800\",\"Application Preferred Name\":\"CREDITO DE VISA\",\"AID\":\"A0000000031010\",\"IAD\":\"06010A03A00000\",\"Entry method\":\"Chip Read\",\"Application Label\":\"VISA CREDIT\"}"

看到您已經(jīng)將它作為string類中注釋掉的類型,AuthCardResponse我希望您已經(jīng)發(fā)現(xiàn)可以將其反序列化為string.


查看完整回答
反對(duì) 回復(fù) 2022-12-31
?
莫回?zé)o

TA貢獻(xiàn)1865條經(jīng)驗(yàn) 獲得超7個(gè)贊

您可以在線使用 JSON to Csharp 檢查您的 C# 類

您需要更多步驟才能通過DeserializeemvTagData 為您的對(duì)象獲取結(jié)果。

http://json2csharp.com/

在此處輸入圖像描述 使用您的 JSON 數(shù)據(jù),您的課程應(yīng)該是

public class RootObject

{

    public string amount { get; set; }

    public string resptext { get; set; }

    public string cvvresp { get; set; }

    public string respcode { get; set; }

    public string avsresp { get; set; }

    public string merchid { get; set; }

    public string token { get; set; }

    public string authcode { get; set; }

    public string respproc { get; set; }

    public string emvTagData { get; set; }

    public string retref { get; set; }

    public string respstat { get; set; }

    public string account { get; set; }

}


查看完整回答
反對(duì) 回復(fù) 2022-12-31
?
喵喔喔

TA貢獻(xiàn)1735條經(jīng)驗(yàn) 獲得超5個(gè)贊

您的 json 的 Newtonsoft.Json 語法錯(cuò)誤。您的 json 中的對(duì)象 (EmvTagData) 應(yīng)如下所示:


"emvTagData": {

"TVR": "0200008000",

"PIN": "None",

"Signature": "true",

"Mode": "Issuer",

"ARC": "Z3",

"TSI": "E800",

"Application Preferred Name": "CREDITO DE VISA",

"AID": "A0000000031010",

"IAD": "06010A03A00000",

"Entry method": "Chip Read",

"Application Label": "VISA CREDIT"}

主括號(hào)前后沒有 \" 和 "。


整個(gè) json :


{"amount":"3.00","resptext":"Approval","cvvresp":"P","respcode":"000","avsresp":"","merchid":"800000000800","token":"9478837814450119","authcode":"PPS306","respproc":"RPCT","emvTagData":{"TVR":"0200008000","PIN":"None","Signature":"true","Mode":"Issuer","ARC":"Z3","TSI":"E800","Application Preferred Name":"CREDITO DE VISA","AID":"A0000000031010","IAD":"06010A03A00000","Entry method":"Chip Read","Application Label":"VISA CREDIT"},"retref":"116390139157","respstat":"A","account":"47XXXXXXXXXX0119"}



查看完整回答
反對(duì) 回復(fù) 2022-12-31
  • 3 回答
  • 0 關(guān)注
  • 183 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)