I am receiving this weird Json string from an API, that also contains the schema within it. I am trying to convert it to a simple model and I am not being able to do it because of this schema structure.
The Json sample is:
[{
"key":null,
"value":{"session_id":{"string":"xxxxx"},
"title_id_type":{"string":"server"},
"event_name":{"string":"achievement"},
"event_type":{"string":"server"},
"event_step":{"int":8},
"country":{"string":"US"},
"event_params":{"map":{"cdur":"416","gdur":"416","sdur":"416","tdur":"0","type":"challenge","percent":"100","status":"expired"}},
"device_id_map":{"map":{}},
"experiment_id_list":{"array":[]}
]}
I would expect this model to be:
public class MyModel
{
[JsonProperty("session_id")]
public string SessionId {get;set;}
[JsonProperty("title_id_type")]
public string TitleIdType{get;set;}
[JsonProperty("event_step")]
public int EventStep {get;set;}
...
}
So far, my tests resulted in objects where those string and int are property names, messing up the whole thing.
How could I deserialize such Json in a clean way? I am using .NET Core 5 and Newtonsoft.Json but no restrictions for a new library.
[JsonProperty]attribute comes from Json.NET.Newtonsoft.Jsonbut no restrictions to change it.