0
How I have to create my class in C# to be able to serialize this json that comes in a request for my API?
[{
"name": "campo_normal_1",
"value": "valor do campo 1 normal"
},
{
"name": "campo_lista_1",
"value":
[
{
"name": "campo_1_da_lista",
"value": "valor do campo 1 da lista"
},{
"name": "campo_2_da_lista",
"value": "valor do campo 2 da lista"
},{
"name": "campo_3_da_lista",
"value":
[{
"name": "campo_1_da_lista",
"value": "valor do campo 1 da lista"
},{
"name": "campo_2_da_lista",
"value": "valor do campo 2 da lista"
}]
}]
}]
Right now I have class this way:
public class FieldRequest
{
public string name { get; set; }
public object value { get; set; }
}
In the controller I try to serialize the field value
to a list of FieldRequest
, but is there a way to get the fields all serialized correctly? I need something like a Overload where my parameter value
be a string or a list of FieldRequest
.