I have the following situation. I am getting an array of log types, and each log object has a type property. Based upon that type property, the rest of the json should be deserialized to another class.
As you can see from the sample below, the first entry in the logs array is of type event
and the second one is customproperties
. They both have a properties
type but for event it’s a Dictionary
and for the customproperty
it is a custom class.
Can this be done with ServiceStack.Text Json?
Sample:
{
"logs": [
{
"type": "event",
"timestamp": "2018-03-17T00:13:32.968Z",
"sid": "0bdacf05-4695-4dc3-8731-eb24070eded6",
"properties": {
"Duration": "1s"
},
"id": "e8104834-f164-4405-b5ab-e8049937214c",
"name": "APP - NestConnect"
},
{
"type": "customProperties",
"timestamp": "2018-03-17T00:54:46.750Z",
"sid": "7BEC100B-E8E8-4910-8ED1-6EF830F09306",
"properties": [
{
"type": "string",
"value": "user@gmail.com",
"name": "Email"
},
{
"type": "string",
"value": "John Doe",
"name": "Name"
}
]
}
]
}