我有以下课程......
[JsonObject]
public class Response
{
[JsonProperty]
public RequestStatusCode StatusCode { get; set; }
[JsonProperty]
public String StatusMessage { get; set; }
[JsonProperty]
public Dictionary<String,String> response { get; set; }
[JsonProperty]
public DataSet dataResponse { get; set; }
public Response()
{
StatusMessage = String.Empty;
response = new Dictionary<string, string>();
dataResponse = new DataSet();
}
}
使用JsonConvert.SerializeObject(myObject)
使用JSON.NET进行序列化后,我得到以下漂亮的JSON字符串(仅作为示例):
{"StatusCode":0,"StatusMessage":"Succeed.","response":{},"dataResponse":{"Table":[{"LabelID":355,"ProductID":1005,"InternalPN":"111INT","Description":"Produs2","WorkOrderSerialNumber":"0000000005","LabelNumber":1,"BarCode":"P000000000500001","Pallet":true,"LabelStatusID":1,"StatusName":"Printed","UserIDAddStatus":1004,"UserNameAddStatus":"test1","DataAddStatus":"2017-03-15T18:42:27.01","IsValidScan":false}]}}
好吧,问题出现在是时候重新创建原始对象了
myObject =JsonConvert.DeserializeObject<Response>(json)
DataSet
属性dataResponse
中的没有加载数据。除此之外,所有其他属性都可以。没有错误,没有任何错误。
有没有使用JSON.NET重新创建原始对象的解决方案?
非常感谢!