1
我只需遵循json和類,我想要DeserializeObject對象。JsonConvert不正確反序列化對象
{"UnsubscribeResponse": {
"txId": "123",
"result": "Success",
"message": "OK"
}}
public class UnsubscribeResponse
{
public string TxId { get; set; }
public string Result { get; set; }
public string Message { get; set; }
}
我剛剛嘗試使用以下方法,但其中任何人都適合我。
unsubscribeResponse = await response.Content.ReadAsAsync<UnsubscribeResponse>();
unsubscribeResponse = JsonConvert.DeserializeObject<UnsubscribeResponse>(contents, new JsonSerializerSettings()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
ObjectCreationHandling = ObjectCreationHandling.Auto
});
的唯一方法,它工作,我不得不使用JObject類象下面這樣:
var resp = JObject.Parse(contents).SelectToken("UnsubscribeResponse");
任何人都已經有這個問題,能幫幫我嗎?
答案幫助@michelalmeida? – mjwills