解決方法:函數
給T類加上帶參的構造函數,爲成員變量賦值this
一開始個人T類以下:blog
public class OrderQueryParam : QueryParam { public string TypeCode { get; set; } public string Type { get; set; } public string Status { get; set; } public string StartTime { get; set; } public string EndTime { get; set; } public string TraderId { get; set; } public string Token { get; set; } }
JsonConvert.DeserializeObject<OrderQueryParam>反序列化後結果部分屬性爲Null,token
後面加了個帶參構造函數(以下),就獲得正確結果了get
public class OrderQueryParam : QueryParam { public string TypeCode { get; set; } public string Type { get; set; } public string Status { get; set; } public string StartTime { get; set; } public string EndTime { get; set; } public string TraderId { get; set; } public string Token { get; set; } public OrderQueryParam(string typeCode,string type,string status,string startTime,string endTime,string traderId,string token) { this.TypeCode = typeCode; this.Type = type; this.Status = status; this.StartTime = startTime; this.EndTime = endTime; this.TraderId = traderId; this.Token = token; } }