I have a JSON string in my project like: (comes from an API call) (I also search first but nothing found that match my situation)
"
{
"property": [
{
"property_1": 1,
"property_2": true,
"property_3": [
{
"property_3_1": 11,
"property_3_2": "value_3_2_1",
"property_3_3": true
},
{
"property_3_1": 12,
"property_3_2": "value_3_2_2",
"property_3_3": false
}
]
},
{
"property_1": 2,
"property_2": false,
"property_3": [
{
"property_3_1": 21,
"property_3_2": "value_3_2_2",
"property_3_3": false
},
{
"property_3_1": 22,
"property_3_2": "value_3_2_2",
"property_3_3": true
}
]
}
]
}
"
I need to deserialize this to list of below class:
public class PropertyDto
{
public long Property_1 { get; set; }
public bool property_2 { get; set; }
public string property_3 { get; set; }
}
Is there any way to deserialize array of "property_3" as string? something like:
var peroperty = new PropertyDto();
peroperty.Peroperty_3 = "
[
{
"property_3_1": 21,
"property_3_2": "value_3_2",
"property_3_3": false
},
{
"property_3_1": 12,
"property_3_2": "value_3_2_2",
"property_3_3": false
}
]
"
Asp.Net Core 5 | System.Text.Json