Using C#, Newtonsoft.Json 13.0.2 and having the following possible JSONs:
Json type 1 ---------------------
{
  "type": "succeeded",
  "event_date": "2023",
  "transaction": {
    "id": "AAA",
    "authorization": "123",
    "operation_type": "456"
  }
}
Json type 2 ---------------------
{
  "type": "failed",
  "event_date": "2023",
  "failureReport": {
    "id": "AAA",
    "failureType": "123"      
  }
}
I'm using the following code to deserialize any of the two objects as follows:
[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<TestClass>(oneOfTwoPossiblejsonTexts.ToString());
//...Code for saving testClass using EntityFramrwork...
With the aforementioned code I'm able to get the values for type and event_date without problem. However I'm unable to populate id, authorization, operation_type, failureReportId, orfailureReportType. I guess the problem is my [JsonPropertyName] tag. Please, how could I correct it to access the required values?
 
     
    