Json type 1 ----------------- ----
Код: Выделить всё
{
"type": "succeeded",
"event_date": "2023",
"transaction": {
"id": "AAA",
"authorization": "123",
"operation_type": "456"
}
}
Код: Выделить всё
{
"type": "failed",
"event_date": "2023",
"failureReport": {
"id": "AAA",
"failureType": "123"
}
}
Код: Выделить всё
[Table("MySql_Test_Table")]
public class TestClass
{
[Key]
[JsonPropertyName("id")]
public int id { get; set; }
[JsonPropertyName("event_date")]
public DateTime? event_date { get; set; }
[JsonPropertyName("type")]
public String? type { get; set; }
[JsonPropertyName("transaction.id")]
public String? transaction_id { get; set; }
[JsonPropertyName("transaction.authorization")]
public String? authorization{ get; set; }
[JsonPropertyName("transaction.operation_type")]
public String? operation_type{ get; set; }
[JsonPropertyName("failureReport.id")]
public String? failureReportId{ get; set; }
[JsonPropertyName("failureReport.failureType")]
public String? failureReportType{ get; set; }
}
TestClass testClass = Newtonsoft.Json.JsonConvert.DeserializeObject(oneOfTwoPossiblejsonTexts.ToString());
//...Code for saving testClass using EntityFramrwork...
Полагаю, проблема в моем теге [JsonPropertyName]. Подскажите, пожалуйста, как это исправить, чтобы получить доступ к необходимым значениям?
Подробнее здесь: https://stackoverflow.com/questions/754 ... tyname-tag