解决方法:
给T类加上带参的构造函数,为成员变量赋值
一开始我的T类如下:
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,
后面加了个带参构造函数(如下),就得到正确结果了
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; } }