我有一个在 3 种不同情况下具有 1 个不同属性的 json 主体
我尝试了一些自定义方法,但都没有奏效。这是我的 jsonBody
var postParameters = new CredoPayRequest()
{
amount = amount,
birthDate = Dob,
currency = "GEL",
currencyRate = 1,
depositId = credoPayId,
fee = 0,
paymentDate = trx_date,
personalNumber = personalNumber,
terminalId = terminalId.ToString(),
transactionId = invoiceID
};
depositId 是以不同方式不同的东西,有时它会是 depositId 有时是 utilityId 和 loanId 。我能做些什么来改变这个价值而不是创造3个不同的身体?我的班级是
public class CredoPayRequest
{
public string personalNumber { get; set; }
public string transactionId { get; set; }
public string terminalId { get; set; }
public string paymentDate { get; set; }
public string birthDate { get; set; }
public string amount { get; set; }
public int fee { get; set; }
public string currency { get; set; }
public int currencyRate { get; set; }
public string accountId { get; set; }
public string depositId { get; set; }
public string utilityId { get; set; }
}
实用程序必须是这样的:
var postParameters = new CredoPayRequest()
{
amount = amount,
birthDate = Dob,
currency = "GEL",
currencyRate = 1,
utilityId = credoPayId,
fee = 0,
paymentDate = trx_date,
personalNumber = personalNumber,
terminalId = terminalId.ToString(),
transactionId = invoiceID
};
那么帐户必须是
var postParameters = new CredoPayRequest()
{
amount = amount,
birthDate = Dob,
currency = "GEL",
currencyRate = 1,
accountId = credoPayId,
fee = 0,
paymentDate = trx_date,
personalNumber = personalNumber,
terminalId = terminalId.ToString(),
transactionId = invoiceID
};