1
我試圖返回一個如下所示的JSON數據集。讓我告訴我說我僅限於Visual Studio 2010和.NET 4.0。我怎麼輸出NULL或轉換爲空白?對輸出緩衝區C使用NULL值解除分解的JSON#
"Application": {
"AppID": 3119385,
"ReportID": 4171130,
"AppReference": "Doran 23-Nov-16 10:46:59AM",
"CreateDT": "2016-11-23 10:48:38.5800000",
"ClientName": "GoGetta Brisbane",
"StoreName": "Brokers",
"Email": "",
"StoreCode": "GGT08",
"AppShortReference": "02",
"ClientNameShort": "GGT Bris",
"StoreNameShort": "GGT08",
"VerifyEmployer": null,
"VerifyAmount": null,
"VerifyFrequency": null,
"VerifyWeekday": null,
"LocalityCode": "en_AU",
"TemplateReportID": 12,
"daysRange": 90,
"templateReportName": "Enhanced Income Liabilities Full Report",
"isReportGraphEnabled": 1,
我想將其處理成SSIS腳本組件的輸出緩衝區。不過,儘管檢查它,我仍然收到「無法將null轉換爲值類型」錯誤。
if (String.IsNullOrEmpty(rptContentOutput.Applications.Application.VerifyEmployer) == true)
{
ApplicationDetailsBuffer.VerifyEmployer = "";
}
else
{
ApplicationDetailsBuffer.VerifyEmployer = rptContentOutput.Applications.Application.VerifyEmployer;
}
我的課程定義如下。
public class Application
{
[JsonProperty("AppID")]
public int? AppID { get; set; }
[JsonProperty("ReportID")]
public int? ReportID { get; set; }
[JsonProperty("AppReference")]
public string AppReference { get; set; }
[JsonProperty("CreateDT")]
public string CreateDT { get; set; }
[JsonProperty("ClientName")]
public string ClientName { get; set; }
[JsonProperty("StoreName")]
public string StoreName { get; set; }
[JsonProperty("Email")]
public string Email { get; set; }
[JsonProperty("StoreCode")]
public string StoreCode { get; set; }
[JsonProperty("AppShortReference")]
public string AppShortReference { get; set; }
[JsonProperty("ClientNameShort")]
public string ClientNameShort { get; set; }
[JsonProperty("StoreNameShort")]
public string StoreNameShort { get; set; }
[JsonProperty("VerifyEmployer")]
public string VerifyEmployer { get; set; }
[JsonProperty("VerifyAmount")]
public double VerifyAmount { get; set; }
[JsonProperty("VerifyFrequency")]
public string VerifyFrequency { get; set; }
[JsonProperty("VerifyWeekday")]
public string VerifyWeekday { get; set; }
[JsonProperty("LocalityCode")]
public string LocalityCode { get; set; }
[JsonProperty("TemplateReportID")]
public int? TemplateReportID { get; set; }
[JsonProperty("daysRange")]
public int? daysRange { get; set; }
[JsonProperty("templateReportName")]
public string templateReportName { get; set; }
[JsonProperty("isReportGraphEnabled")]
public string isReportGraphEnabled { get; set; }
}
您不指定什麼是「VerifyFrequency」 - 是那些類或結構? – LB2
@ LB2你是什麼意思。我還沒有輸出,因爲我可以得到第一個值。 –
也許我誤解了這個問題:你想要序列化成JSON,還是從JSON反序列化? – LB2