I am using the following class -
public class RequestObject
{
public string loanPurpose { get; set; }
public string occupancy { get; set; }
public string propertyType { get; set; }
public string condoStyle { get; set; }
public int purchasePrice { get; set; }
public string propertyValue { get; set; }
public double loanAmount { get; set; }
public int loanAmountPCT { get; set; }
public string secondLien { get; set; }
public string maxLimit { get; set; }
public string curBalance { get; set; }
public string disposition { get; set; }
public string openedDate { get; set; }
public int zipcode { get; set; }
public string creditScore { get; set; }
public string loanProgram { get; set; }
public string pleaseSpecify { get; set; }
public string orgPurchasePrice { get; set; }
public string cmYearStart { get; set; }
public string escrowAccount { get; set; }
public string unitsNo { get; set; }
public string lockPeriod { get; set; }
public string payoffAmount { get; set; }
public string f1OptStatus { get; set; }
}
I am building an object from the class like so -
var jsonObject = new RequestObject
{
loanPurpose = "Purchase",
occupancy = "Primary Residence",
propertyType = "Townhouse",
condoStyle = "Attached",
purchasePrice = purchasePrice,
propertyValue = null,
loanAmount = actualLoanAmount,
loanAmountPCT = loanPercent,
secondLien = null,
maxLimit = null,
curBalance = null,
disposition = null,
openedDate = null,
zipcode = zipCode,
creditScore = "780 +",
loanProgram = "30 Year Fixed",
pleaseSpecify = null,
orgPurchasePrice = null,
cmYearStart = null,
escrowAccount = "With Escrow Account",
unitsNo = null,
lockPeriod = "30 Days",
payoffAmount = null,
f1OptStatus = "No"
};
I am then calling the Serialize method -
var json = request.JsonSerializer.Serialize(jsonObject);
When I execute my application, I get 'Object reference not set to an instance of an object' on the Serialize method line.
I thought I am building the object correctly. What is going wrong?
Thank you!