我遇到問題將JSON字符串反序列化後返回到輸出。將JSON返回給OutputBuffer
我有以下三個類聲明,我從json2csharp生成。
public class Application
{
public int App_ID { get; set; }
public string App_Ref { get; set; }
public string Status { get; set; }
public string Error_Code { get; set; }
public string Error_Message { get; set; }
public string Create_Dt { get; set; }
public string Modify_Dt { get; set; }
public string Client_Name { get; set; }
public string Client_Code { get; set; }
public string Centrelink_Status { get; set; }
}
public class Response
{
public List<Application> Applications { get; set; }
public string Current_Dt { get; set; }
public string Last_App_Dt { get; set; }
public int Count { get; set; }
public int Total { get; set; }
}
public class RootObject
{
public bool Success { get; set; }
public Response jsonResponse { get; set; }
}
我的JSON響應看起來像這樣。
{
"Success": true,
"Response": {
"Applications": [
{
"App_ID": 2877582,
"App_Ref": "Odonnell",
"Status": "Complete",
"Error_Code": 0,
"Error_Message": "",
"Create_Dt": "2016-10-09 19:28:18.867 +00:00",
"Modify_Dt": "2016-10-09 19:33:10.810 +00:00",
"Client_Name": "Aussie Bike Auto & Boat Loans South",
"Client_Code": "GGT31",
"Centrelink_Status": "Receiving_Logons"
},
{
"App_ID": 2878070,
"App_Ref": "alliso",
"Status": "Quicklink",
"Error_Code": null,
"Error_Message": null,
"Create_Dt": "2016-10-09 21:55:49.220 +00:00",
"Modify_Dt": "2016-10-09 21:55:49.220 +00:00",
"Client_Name": "KChristoforidis",
"Client_Code": "GGT05",
"Centrelink_Status": "Receiving_Logons"
}...
],
"Current_Dt": "2016-11-13 22:52:41.581 +00:00",
"Last_App_Dt": "2016-10-11 01:42:25.470 +00:00",
"Count": 65,
"Total": 65
}
}
我能夠輸出響應「成功」布爾,但我無法找回任何東西從響應別的,因爲我得到一個「對象引用不設置到對象的實例。 「我嘗試執行以下操作時出現錯誤。
foreach (Application app in outPutResponse.jsonResponse.Applications)
{
ApplicationBuffer.AddRow();
ApplicationBuffer.AppID = app.App_ID;
ApplicationBuffer.AppRef = app.App_Ref;
ApplicationBuffer.Status = app.Status;
}
我也不能返回響應「jsonResponse」到OutputBuffer中帶有「不能隱式轉換jsonResponse到BlobColumn」
我也無法從outPutResponse.jsonResponse與以下錯誤返回的響應值。
RawBuffer.AddRow();
RawBuffer.ResponseSuccess = outPutResponse.Success;
RawBuffer.Response.AddBlobData(Encoding.ASCII.GetBytes(outPutResponse.jsonResponse));
的最好重載方法匹配 'System.Text.Encoding.GetBytes(炭[])' 具有一些無效參數 參數1:不能從 'Script.Response' 轉換到 '字符[]'
這是我最後的絆腳石,無法得到正確的結果。誰能幫忙?提前致謝。
你不知道我現在多麼欣賞這個 –
@LucasPerrett你的歡迎 – Jim