我有一个函数返回JSON,如下所示:
jsonParsed = {
"account-number": "xxxxxxxx",
"symbol": "XLE 230120C00070000",
"instrument-type": "Equity Option",
"underlying-symbol": "XLE",
"quantity": 3,
"quantity-direction": "Short",
"close-price": "7.64",
"average-open-price": "7.95",
"average-yearly-market-close-price": "7.95",
"average-daily-market-close-price": "7.64",
"multiplier": 100,
"cost-effect": "Debit",
"is-suppressed": false,
"is-frozen": false,
"restricted-quantity": 0,
"expires-at": "2023-01-20T15:15:00-06:00",
"realized-day-gain": "0.0",
"realized-day-gain-effect": "None",
"realized-day-gain-date": "2022-07-05",
"realized-today": "0.0",
"realized-today-effect": "None",
"realized-today-date": "2022-07-05",
"created-at": "xxxx-xx-xxxxx:xx:xx.xxx-xx:00",
"updated-at": "xxxx-xx-xxxxx:xx:xx.xx-xx:00"
}
我正在try 将其反序列化为C#类:
public class PositionResult
{
public string AccountNumber { get; set; }
public string Symbol { get; set; }
public string InstrumentType { get; set; }
public string UnderlyingSymbol { get; set; }
public string Quantity { get; set; }
public string QuantityDirection { get; set; }
public string ClosePrice { get; set; }
public string AverageOpenPrice { get; set; }
public string AverageYearlyMarketClosePrice { get; set; }
public string AverageDailyMarketClosePrice { get; set; }
public string multiplier { get; set; }
public string CostEffect { get; set; }
public string IsSuppressed { get; set; }
public string IsFrozen { get; set; }
public string RestrictedQuantity { get; set; }
public string ExpiresAt { get; set; }
public string RealizedDayGain { get; set; }
public string RealizedDayGainEffect { get; set; }
public string RealizedDayGainDate { get; set; }
public string RealizedToday { get; set; }
public string RealizedTodayEffect { get; set; }
public string RealizedTodayDate { get; set; }
public string CreatedAt { get; set;}
public string UpdatedAt { get; set;}
public override string ToString()
{
return this.ReportAllProperties();
}
}
dataDeSerialized = JsonConvert.DeserializeObject<PositionResult>(jsonParsed, new
JsonSerializerSettings()
{
NullValueHandling = NullValueHandling.Ignore
});
然而,除了少数例外,dataDeSerialized
中的大多数字段都是空的.我怀疑"xxxx" : "xxxx"
格式有问题,但我不确定我做错了什么?