I am looking for the proper way to have a variable property name on serialization.
Example outputs:
{
"header": {
"total": 3,
"page": 1,
"pagesize": 30
},
"cats": [
..
]
}
and
{
"header": {
"total": 3,
"page": 1,
"pagesize": 30
},
"dogs": [
..
]
}
I would like to have the name of the array be variable and assign it somehow somewhere. If I am creating a page of cats I want to have the name "cats" on output, if I am creating a page of dogs I want to have the name "dogs" on output. I am using a single class the represents such a page with a list of things (dogs or cats). Currently I am duplicating that class with the only variant being the name of the array which seems a bit not ok.
T.I.A. a lot