我正在使用返回JSON的Web API。在該JSON中,返回一個base64編碼的JSON字符串。在C#中嵌套的JSON反序列化SSIS
初始響應返回使用以下類的JSON。
public class Attachment
{
public string type { get; set; }
public string name { get; set; }
public string contentType { get; set; }
public string content { get; set; }
}
public class Response
{
public int postVersion { get; set; }
public int appId { get; set; }
public string appReference { get; set; }
public string createDate { get; set; }
public string clientName { get; set; }
public string storeName { get; set; }
public List<Attachment> attachments { get; set; }
}
public class RootObject
{
public bool Success { get; set; }
public Response Response { get; set; }
}
在Attachment
類的「內容」則返回base64編碼JSON字符串。
一旦解碼的JSON刺痛使用(這是從json2csharp.com產生)以下類
public class Salary
{
public int AccountID { get; set; }
public string H1 { get; set; }
public string H2 { get; set; }
public string H3 { get; set; }
public string SH1 { get; set; }
public string Description { get; set; }
public object Count { get; set; }
public object FrequencyDescription { get; set; }
public object FrequencyDuration { get; set; }
public object FrequencyDurationDate { get; set; }
public object FrequencyWeekday { get; set; }
public object FrequencyAmount { get; set; }
public object FrequencyAmountRange { get; set; }
public object TotalAmount { get; set; }
public object TotalInAmount { get; set; }
public object TotalOutAmount { get; set; }
public object MonthlyAmount { get; set; }
public object GroupID { get; set; }
public object Display { get; set; }
public object FrequencyExactness { get; set; }
public object FrequencyPeriod { get; set; }
public object ScoreEmployer { get; set; }
public object ScoreDirCr { get; set; }
public object ScoreWeekday { get; set; }
public object ScoreFrequency { get; set; }
public object ScoreAmount { get; set; }
public object ScoreTotal { get; set; }
}
public class Benefit
{
public int AccountID { get; set; }
public string H1 { get; set; }
public string H2 { get; set; }
public string H3 { get; set; }
public string SH1 { get; set; }
public string Description { get; set; }
public object Count { get; set; }
public object FrequencyDescription { get; set; }
public object FrequencyDuration { get; set; }
public object FrequencyDurationDate { get; set; }
public object FrequencyWeekday { get; set; }
public object FrequencyAmount { get; set; }
public object FrequencyAmountRange { get; set; }
public object TotalAmount { get; set; }
public object TotalInAmount { get; set; }
public object TotalOutAmount { get; set; }
public object MonthlyAmount { get; set; }
public object GroupID { get; set; }
public object Display { get; set; }
public object FrequencyExactness { get; set; }
public object FrequencyPeriod { get; set; }
public object ScoreEmployer { get; set; }
public object ScoreDirCr { get; set; }
public object ScoreWeekday { get; set; }
public object ScoreFrequency { get; set; }
public object ScoreAmount { get; set; }
public object ScoreTotal { get; set; }
}
public class OtherIncome
{
public int AccountID { get; set; }
public string H1 { get; set; }
public string H2 { get; set; }
public string H3 { get; set; }
public string SH1 { get; set; }
public string Description { get; set; }
public int Count { get; set; }
public string FrequencyDescription { get; set; }
public string FrequencyDuration { get; set; }
public string FrequencyDurationDate { get; set; }
public string FrequencyWeekday { get; set; }
public double FrequencyAmount { get; set; }
public string FrequencyAmountRange { get; set; }
public double TotalAmount { get; set; }
public double TotalInAmount { get; set; }
public int TotalOutAmount { get; set; }
public int MonthlyAmount { get; set; }
public string GroupID { get; set; }
public string Display { get; set; }
public string FrequencyExactness { get; set; }
public string FrequencyPeriod { get; set; }
public object ScoreEmployer { get; set; }
public object ScoreDirCr { get; set; }
public object ScoreWeekday { get; set; }
public object ScoreFrequency { get; set; }
public object ScoreAmount { get; set; }
public int ScoreTotal { get; set; }
}
public class Income
{
public List<Salary> Salary { get; set; }
public List<Benefit> Benefits { get; set; }
public List<OtherIncome> __invalid_name__Other Income { get; set; }
}
public class SmallAmountLoan
{
public int AccountID { get; set; }
public string H1 { get; set; }
public string H2 { get; set; }
public string H3 { get; set; }
public string SH1 { get; set; }
public string Description { get; set; }
public int? Count { get; set; }
public string FrequencyDescription { get; set; }
public string FrequencyDuration { get; set; }
public string FrequencyDurationDate { get; set; }
public string FrequencyWeekday { get; set; }
public int? FrequencyAmount { get; set; }
public string FrequencyAmountRange { get; set; }
public int? TotalAmount { get; set; }
public int? TotalInAmount { get; set; }
public int? TotalOutAmount { get; set; }
public int? MonthlyAmount { get; set; }
public string GroupID { get; set; }
public string Display { get; set; }
public string FrequencyExactness { get; set; }
public string FrequencyPeriod { get; set; }
public object ScoreEmployer { get; set; }
public object ScoreDirCr { get; set; }
public object ScoreWeekday { get; set; }
public object ScoreFrequency { get; set; }
public object ScoreAmount { get; set; }
public int? ScoreTotal { get; set; }
}
public class SmallAmountRepayment
{
public int AccountID { get; set; }
public string H1 { get; set; }
public string H2 { get; set; }
public string H3 { get; set; }
public string SH1 { get; set; }
public string Description { get; set; }
public int Count { get; set; }
public string FrequencyDescription { get; set; }
public string FrequencyDuration { get; set; }
public string FrequencyDurationDate { get; set; }
public string FrequencyWeekday { get; set; }
public double FrequencyAmount { get; set; }
public string FrequencyAmountRange { get; set; }
public double TotalAmount { get; set; }
public int TotalInAmount { get; set; }
public double TotalOutAmount { get; set; }
public double MonthlyAmount { get; set; }
public string GroupID { get; set; }
public string Display { get; set; }
public string FrequencyExactness { get; set; }
public string FrequencyPeriod { get; set; }
public object ScoreEmployer { get; set; }
public object ScoreDirCr { get; set; }
public object ScoreWeekday { get; set; }
public object ScoreFrequency { get; set; }
public object ScoreAmount { get; set; }
public int ScoreTotal { get; set; }
}
public class OtherLoan
{
public int AccountID { get; set; }
public string H1 { get; set; }
public string H2 { get; set; }
public string H3 { get; set; }
public string SH1 { get; set; }
public string Description { get; set; }
public object Count { get; set; }
public object FrequencyDescription { get; set; }
public object FrequencyDuration { get; set; }
public object FrequencyDurationDate { get; set; }
public object FrequencyWeekday { get; set; }
public object FrequencyAmount { get; set; }
public object FrequencyAmountRange { get; set; }
public object TotalAmount { get; set; }
public object TotalInAmount { get; set; }
public object TotalOutAmount { get; set; }
public object MonthlyAmount { get; set; }
public object GroupID { get; set; }
public object Display { get; set; }
public object FrequencyExactness { get; set; }
public object FrequencyPeriod { get; set; }
public object ScoreEmployer { get; set; }
public object ScoreDirCr { get; set; }
public object ScoreWeekday { get; set; }
public object ScoreFrequency { get; set; }
public object ScoreAmount { get; set; }
public object ScoreTotal { get; set; }
}
public class OtherRepayment
{
public int AccountID { get; set; }
public string H1 { get; set; }
public string H2 { get; set; }
public string H3 { get; set; }
public string SH1 { get; set; }
public string Description { get; set; }
public object Count { get; set; }
public object FrequencyDescription { get; set; }
public object FrequencyDuration { get; set; }
public object FrequencyDurationDate { get; set; }
public object FrequencyWeekday { get; set; }
public object FrequencyAmount { get; set; }
public object FrequencyAmountRange { get; set; }
public object TotalAmount { get; set; }
public object TotalInAmount { get; set; }
public object TotalOutAmount { get; set; }
public object MonthlyAmount { get; set; }
public object GroupID { get; set; }
public object Display { get; set; }
public object FrequencyExactness { get; set; }
public object FrequencyPeriod { get; set; }
public object ScoreEmployer { get; set; }
public object ScoreDirCr { get; set; }
public object ScoreWeekday { get; set; }
public object ScoreFrequency { get; set; }
public object ScoreAmount { get; set; }
public object ScoreTotal { get; set; }
}
public class Loans
{
public List<SmallAmountLoan> __invalid_name__Small Amount Loans { get; set; }
public List<SmallAmountRepayment> __invalid_name__Small Amount Repayments { get; set; }
public List<OtherLoan> __invalid_name__Other Loans { get; set; }
public List<OtherRepayment> __invalid_name__Other Repayments { get; set; }
}
public class Dishonour
{
public int AccountID { get; set; }
public string H1 { get; set; }
public string H2 { get; set; }
public string H3 { get; set; }
public string SH1 { get; set; }
public string Description { get; set; }
public int? Count { get; set; }
public string FrequencyDescription { get; set; }
public string FrequencyDuration { get; set; }
public string FrequencyDurationDate { get; set; }
public string FrequencyWeekday { get; set; }
public double? FrequencyAmount { get; set; }
public string FrequencyAmountRange { get; set; }
public double? TotalAmount { get; set; }
public double? TotalInAmount { get; set; }
public int? TotalOutAmount { get; set; }
public double? MonthlyAmount { get; set; }
public string GroupID { get; set; }
public string Display { get; set; }
public string FrequencyExactness { get; set; }
public string FrequencyPeriod { get; set; }
public object ScoreEmployer { get; set; }
public object ScoreDirCr { get; set; }
public object ScoreWeekday { get; set; }
public object ScoreFrequency { get; set; }
public object ScoreAmount { get; set; }
public int? ScoreTotal { get; set; }
}
public class Dishonours
{
public List<Dishonour> Dishonours { get; set; }
}
public class HighRiskMerchant
{
public int AccountID { get; set; }
public string H1 { get; set; }
public string H2 { get; set; }
public string H3 { get; set; }
public string SH1 { get; set; }
public string Description { get; set; }
public object Count { get; set; }
public object FrequencyDescription { get; set; }
public object FrequencyDuration { get; set; }
public object FrequencyDurationDate { get; set; }
public object FrequencyWeekday { get; set; }
public object FrequencyAmount { get; set; }
public object FrequencyAmountRange { get; set; }
public object TotalAmount { get; set; }
public object TotalInAmount { get; set; }
public object TotalOutAmount { get; set; }
public object MonthlyAmount { get; set; }
public object GroupID { get; set; }
public object Display { get; set; }
public object FrequencyExactness { get; set; }
public object FrequencyPeriod { get; set; }
public object ScoreEmployer { get; set; }
public object ScoreDirCr { get; set; }
public object ScoreWeekday { get; set; }
public object ScoreFrequency { get; set; }
public object ScoreAmount { get; set; }
public object ScoreTotal { get; set; }
}
public class HighRiskMerchants
{
public List<HighRiskMerchant> __invalid_name__High Risk Merchants { get; set; }
}
public class Rent
{
public int AccountID { get; set; }
public string H1 { get; set; }
public string H2 { get; set; }
public string H3 { get; set; }
public string SH1 { get; set; }
public string Description { get; set; }
public int? Count { get; set; }
public string FrequencyDescription { get; set; }
public string FrequencyDuration { get; set; }
public string FrequencyDurationDate { get; set; }
public string FrequencyWeekday { get; set; }
public int? FrequencyAmount { get; set; }
public string FrequencyAmountRange { get; set; }
public int? TotalAmount { get; set; }
public int? TotalInAmount { get; set; }
public int? TotalOutAmount { get; set; }
public int? MonthlyAmount { get; set; }
public string GroupID { get; set; }
public string Display { get; set; }
public string FrequencyExactness { get; set; }
public string FrequencyPeriod { get; set; }
public object ScoreEmployer { get; set; }
public object ScoreDirCr { get; set; }
public object ScoreWeekday { get; set; }
public object ScoreFrequency { get; set; }
public object ScoreAmount { get; set; }
public int? ScoreTotal { get; set; }
}
public class Periodic
{
public int AccountID { get; set; }
public string H1 { get; set; }
public string H2 { get; set; }
public string H3 { get; set; }
public string SH1 { get; set; }
public string Description { get; set; }
public int? Count { get; set; }
public string FrequencyDescription { get; set; }
public string FrequencyDuration { get; set; }
public string FrequencyDurationDate { get; set; }
public string FrequencyWeekday { get; set; }
public double? FrequencyAmount { get; set; }
public string FrequencyAmountRange { get; set; }
public double? TotalAmount { get; set; }
public int? TotalInAmount { get; set; }
public double? TotalOutAmount { get; set; }
public double? MonthlyAmount { get; set; }
public string GroupID { get; set; }
public string Display { get; set; }
public string FrequencyExactness { get; set; }
public string FrequencyPeriod { get; set; }
public object ScoreEmployer { get; set; }
public object ScoreDirCr { get; set; }
public object ScoreWeekday { get; set; }
public object ScoreFrequency { get; set; }
public object ScoreAmount { get; set; }
public int? ScoreTotal { get; set; }
}
public class NonPeriodic
{
public int AccountID { get; set; }
public string H1 { get; set; }
public string H2 { get; set; }
public string H3 { get; set; }
public string SH1 { get; set; }
public string Description { get; set; }
public int Count { get; set; }
public string FrequencyDescription { get; set; }
public string FrequencyDuration { get; set; }
public string FrequencyDurationDate { get; set; }
public string FrequencyWeekday { get; set; }
public double FrequencyAmount { get; set; }
public string FrequencyAmountRange { get; set; }
public double TotalAmount { get; set; }
public int TotalInAmount { get; set; }
public double TotalOutAmount { get; set; }
public int MonthlyAmount { get; set; }
public string GroupID { get; set; }
public string Display { get; set; }
public string FrequencyExactness { get; set; }
public string FrequencyPeriod { get; set; }
public object ScoreEmployer { get; set; }
public object ScoreDirCr { get; set; }
public object ScoreWeekday { get; set; }
public object ScoreFrequency { get; set; }
public object ScoreAmount { get; set; }
public int ScoreTotal { get; set; }
}
public class TopUncommittedSpend
{
public int AccountID { get; set; }
public string H1 { get; set; }
public string H2 { get; set; }
public string H3 { get; set; }
public string SH1 { get; set; }
public string Description { get; set; }
public int? Count { get; set; }
public string FrequencyDescription { get; set; }
public string FrequencyDuration { get; set; }
public string FrequencyDurationDate { get; set; }
public string FrequencyWeekday { get; set; }
public double? FrequencyAmount { get; set; }
public string FrequencyAmountRange { get; set; }
public double? TotalAmount { get; set; }
public double? TotalInAmount { get; set; }
public int? TotalOutAmount { get; set; }
public int? MonthlyAmount { get; set; }
public string GroupID { get; set; }
public string Display { get; set; }
public string FrequencyExactness { get; set; }
public string FrequencyPeriod { get; set; }
public object ScoreEmployer { get; set; }
public object ScoreDirCr { get; set; }
public object ScoreWeekday { get; set; }
public object ScoreFrequency { get; set; }
public object ScoreAmount { get; set; }
public int? ScoreTotal { get; set; }
}
public class Liabilities
{
public List<Rent> Rent { get; set; }
public List<Periodic> Periodic { get; set; }
public List<NonPeriodic> __invalid_name__Non-Periodic { get; set; }
public List<TopUncommittedSpend> __invalid_name__Top Uncommitted Spend { get; set; }
}
public class Overview
{
public Income Income { get; set; }
public Loans Loans { get; set; }
public Dishonours Dishonours { get; set; }
public HighRiskMerchants __invalid_name__High Risk Merchants { get; set; }
public Liabilities Liabilities { get; set; }
}
public class Overviews
{
public Overview Overview { get; set; }
}
public class Transaction
{
public int AccountID { get; set; }
public object TranID { get; set; }
public string CleanDesc { get; set; }
public string Category { get; set; }
public object TranDate { get; set; }
public object TranAmount { get; set; }
public object TranBaseTypeID { get; set; }
public string TranBaseType { get; set; }
public string GroupID { get; set; }
public double Balance { get; set; }
}
public class Transactions
{
public List<Transaction> Transaction { get; set; }
}
public class Account
{
public int AccountID { get; set; }
public string AccountNumber { get; set; }
public string AccountType { get; set; }
public string AccountName { get; set; }
public string AccountHolder { get; set; }
public string SecondaryAccountHolder { get; set; }
public double BankAvailableBalance { get; set; }
public double BankCurrentBalanceOriginal { get; set; }
public double BankCurrentBalance { get; set; }
public object CardMinPayment { get; set; }
public object CardRunningBalance { get; set; }
public object CardLastPaymentAmount { get; set; }
public object CardAvailableCredit { get; set; }
public object CardTotalCreditLine { get; set; }
public object CardDueDate { get; set; }
public object CardLastPaymentDate { get; set; }
public string CreateDT { get; set; }
public int ServiceID { get; set; }
public string BankName { get; set; }
public string AccountBSB { get; set; }
public int DishonourCount { get; set; }
public int DaysRange { get; set; }
public object accountCategoryId { get; set; }
public object accountCategory { get; set; }
public object loanInterestRateTypeId { get; set; }
public object loanInterestRateType { get; set; }
public object loanTerm { get; set; }
public object loanTypeId { get; set; }
public object loanType { get; set; }
public object interestRate { get; set; }
public object dueDateLoan { get; set; }
public object overDraft { get; set; }
public object lastPaymentDate { get; set; }
public double MaxAmountOverdraft { get; set; }
public int DaysOverdraft { get; set; }
public double TotalCredits { get; set; }
public double TotalDebits { get; set; }
public string FirstTransaction { get; set; }
public string LastTransaction { get; set; }
public double DayAgoBalance { get; set; }
public Overviews Overviews { get; set; }
public Transactions Transactions { get; set; }
}
public class Accounts
{
public List<Account> Account { get; set; }
}
public class DecisionPoint
{
public int CriteriaID { get; set; }
public int ReportID { get; set; }
public string Criteria { get; set; }
public string CriteriaName { get; set; }
public string Score { get; set; }
public object ScoreDT { get; set; }
public int CriteriaTypeID { get; set; }
}
public class DecisionPoints
{
public List<DecisionPoint> DecisionPoint { get; set; }
}
public class Application
{
public int AppID { get; set; }
public int ReportID { get; set; }
public string AppReference { get; set; }
public string CreateDT { get; set; }
public string ClientName { get; set; }
public string StoreName { get; set; }
public string Email { get; set; }
public string StoreCode { get; set; }
public string AppShortReference { get; set; }
public string ClientNameShort { get; set; }
public string StoreNameShort { get; set; }
public object VerifyEmployer { get; set; }
public object VerifyAmount { get; set; }
public object VerifyFrequency { get; set; }
public object VerifyWeekday { get; set; }
public string LocalityCode { get; set; }
public int TemplateReportID { get; set; }
public int daysRange { get; set; }
public string templateReportName { get; set; }
public Accounts Accounts { get; set; }
public DecisionPoints DecisionPoints { get; set; }
}
public class Applications
{
public Application Application { get; set; }
}
public class RootObject
{
public Applications Applications { get; set; }
}
隨着2「RootObjects」我需要知道如何聲明這些?
有沒有辦法做到這一點?還是最好輸出它並開發新的腳本?
在此先感謝。
u能展示如何烏爾* Base64編碼JSON字符串*和*解碼json字符串*看起來像? –
這是最初的迴應。 「內容」 是編碼的JSON –
{ 「成功」:真, 「響應」:{ 「postVersion」:2, 「APPID」:2891426, 「appReference」:「塔普林12-OCT-16 10 :37:02AM「, 」createDate「:」2016-10-12 10:36:59.8900000「, 」clientName「:」GoGetta Brisbane「, 」storeName「:」Brokers「, 」attachments「:[ { 「類型」: 「信用意識報告」, 「名」: 「加強收入負債報告全文」, 「的contentType」: 「JSON」, 「內容」: 「eyJBcHBsaWNhdGlvbnMiOnsiQXBwbGljYXRpb24iOnsiQXBwSUQiOjI4OTE0MjYsIlJlcG9ydElEIjo0 ......」 } ] } }' –