我正在尝试将 json 字符串解析为 c# 类对象。我在 c# 中有三个类,我从服务中获取 json 字符串,我正在编码以将此 json 字符串存储到 sql 表中。我在将 json 字符串解析为 c# 中的多个类时遇到问题。我正在使用 newtonsoft.json 进行解析。我有以下 json 字符串
{
"receipt_cr": {
"VchNo": [
"CR::00001",
"CR::00002",
"CR::00003",
"CR::00004",
"CR::00005"
],
"VoucherName": [
"Receipt",
"Receipt",
"Receipt",
"Receipt",
"Receipt"
],
"VchDate": [
"2013-04-02 00:00:00",
"2013-04-02 00:00:00",
"2013-04-02 00:00:00",
"2013-04-02 00:00:00",
"2013-04-02 00:00:00"
],
"LedgerName": [
"xxxxxx",
"yyyyy",
"ssssss",
"rrrrrrr",
"wwwwwww"
],
"UnderGroup": [
"Sundry Debtors",
"Sundry Debtors",
"Sundry Debtors",
"Sundry Debtors",
"Sundry Debtors"
],
"AgnstRefNumber": [
"",
"",
"",
"",
""
],
"NetAmount": [
"2973500.00",
"2973500.00",
"5967015.00",
"8968432.00",
"5980000.00"
],
"AgnstReferenceAmount": [
"",
"",
"",
"",
""
],
"CostCentreName": [
"",
"",
"",
"",
""
],
"CostCategory": [
"",
"",
"",
"",
""
],
"Status ": [
"NI",
"NI",
"NI",
"NI",
"NI"
]
},
"receipt_dr": {
"VchNo": [
"CR::00001",
"CR::00002",
"CR::00003",
"CR::00004",
"CR::00004"
],
"VoucherName": [
"Receipt",
"Receipt",
"Receipt",
"Receipt",
"Receipt"
],
"VchDate": [
"2013-04-02 00:00:00",
"2013-04-02 00:00:00",
"2013-04-02 00:00:00",
"2013-04-02 00:00:00",
"2013-04-02 00:00:00"
],
"CashBankLedger": [
"Bank",
"Bank",
"Bank",
"Bank",
"Bank"
],
"UnderGroup": [
"BankAccount",
"BankAccount",
"BankAccount",
"BankAccount",
"BankAccount"
],
"Amount": [
"2973500.00",
"2973500.00",
"5967015.00",
"2989477.00",
"2989477.00"
],
"TransactionType": [
"cheque",
"RTGS",
"cheque",
"cheque",
"cheque"
],
"InstrumentNo": [
"1",
"2",
"3",
"4",
"5"
],
"Date": [
"2013-04-02 00:00:00",
"2013-04-02 00:00:00",
"2013-04-02 00:00:00",
"2013-04-02 00:00:00",
"2013-04-02 00:00:00"
],
"BankName": [
"Axis - 230",
"Axis - 230",
"Axis - 230",
"Axis - 230",
"Axis - 230"
],
"BankBranch": [
"Avinashi Road",
"Avinashi Road",
"Avinashi Road",
"Avinashi Road",
"Avinashi Road"
],
"BankDate": [
"2013-04-02 00:00:00",
"2013-04-02 00:00:00",
"2013-04-02 00:00:00",
"2013-04-02 00:00:00",
"2013-04-02 00:00:00"
],
"Narration": [
"",
"",
"",
"",
""
]
},
"payment_dr": {
"VchNo": [
"SP::00001",
"SP::00002",
"SP::00003",
"SP::00004",
"SP::00005"
],
"VoucherName": [
"Payment",
"Payment",
"Payment",
"Payment",
"Payment"
],
"VchDate": [
"2013-04-02 13:49:00",
"2013-04-02 13:53:00",
"2013-04-02 13:54:00",
"2013-04-02 13:55:00",
"2013-04-02 13:55:00"
],
"LedgerName": [
"shruthi jewel city",
"TRUST TECHONOLOGIES",
"RKR Gold Pvt Ltd",
"Bank of Nova Scotia",
"Bank of Nova Scotia"
],
"UnderGroup": [
"SundryCredit",
"SundryCredit",
"SundryCredit",
"SundryCredit",
"SundryCredit"
],
"NetAmount": [
"8977387",
"1000",
"14915000",
"14700000",
"27700000"
],
"AgnstRefNumber ": [
"",
"",
"",
"",
""
],
"AgnstReferenceAmount ": [
"",
"",
"",
"",
""
],
"CostCentreName ": [
"",
"",
"",
"",
""
],
"CostCategory ": [
"",
"",
"",
"",
""
],
"Status ": [
"NI",
"NI",
"NI",
"NI",
"NI"
]
}
}
我有我的 C# 类
public class ReceiptCr
{
public String VchNo { get; set; }
public String VoucherName { get; set; }
public DateTime VchDate { get; set; }
public String LedgerName { get; set; }
public String UnderGroup { get; set; }
public Decimal NetAmount { get; set; }
public String AgnstRefNumber { get; set; }
public Decimal AgnstReferenceAmount { get; set; }
public String CostCentreName { get; set; }
public String CostCategory { get; set; }
public String Status { get; set; }
}
public class ReceiptDr
{
public String VchNo { get; set; }
public String VoucherName { get; set; }
public DateTime VchDate { get; set; }
public String CashOrBankLedger { get; set; }
public String UnderGroup { get; set; }
public Decimal Amount { get; set; }
public String TransactionType { get; set; }
public String InstrumentNo { get; set; }
public DateTime BankDate { get; set; }
public String BankName { get; set; }
public String BankBranch { get; set; }
public String Narration { get; set; }
}
public class PaymentDr
{
public String VchNo { get; set; }
public String VoucherName { get; set; }
public DateTime VchDate { get; set; }
public String LedgerName { get; set; }
public String UnderGroup { get; set; }
public Decimal NetAmount { get; set; }
public String AgnstRefNumber { get; set; }
public Decimal AgnstReferenceAmount { get; set; }
public String CostCentreName { get; set; }
public String CostCategory { get; set; }
public String Status { get; set; }
}
如何将此json字符串解析为c#中的这些类