我試圖反序列化JSON字符串,但我得到一個錯誤:用雙引號JSON序列化問題
var response = jss.Deserialize<Dictionary<string,string>>(responseValue);
我得到了一個錯誤:
Type 'System.String' is not supported for deserialization of an array.
我認爲該錯誤會固定如果我改變\"
與'
這是字符串
"{\"data\":[],\"error\":1,\"error_msg\":\"could not find associated database\",\"message\":\"Please check sr_no that you have sent\"}"
我希望它這樣
"{'data':[],'error':1,'error_msg':'could not find associated database','message':'Please check sr_no that you have sent'}"
我曾嘗試使用這一功能如下但對我來說
responseValue.Replace("\"","'");
你_sure_這串是什麼?它看起來只是它的調試器表示。另外,它看起來像是JSON,爲什麼要通過奇怪的字符串操作(特別是使它成爲_invalid_ JSON的字符串),而不是僅僅將它視爲JSON? –
您的代碼有效https://dotnetfiddle.net/nwqUqM – fubo
是的,它是一個調試器代表@JamesThorpe。實際發生的是我反序列化josn使用var response = jss.Deserialize>(responseValue);但是我得到一個錯誤,「類型'System.String'不支持數組的反序列化。」 –
SaMeEr