I'm using newtonsoft json, and I need to serialize/deserialize this kind of json:
[
{
"value": "value1",
"field": "field1"
},
{
"value": "value2",
"field": "field2"
},
{
"value": "value3",
"field": "field3"
},
[
{
"value": "value4",
"field": "field4"
},
{
"value": "value4",
"field": "field5"
}
]
]
As you can see, I can have an object or a list of this object at the same level. I've created a class for the object but I don't know how to make the serialization process this kind of json, or if it's possible to do.
EDIT: I don't have the choice to process that json as it comes to me. So please, if you think I like this, you're wrong.
>` where standalone objects get mapped to a list with one value. To do that, you can use one of the converters from [How to handle both a single item and an array for the same property using JSON.net](https://stackoverflow.com/q/18994685/3744182).
– dbc Jul 04 '23 at 14:50> NestedItems. Then I parse the JToken, then check the type and populate the right property.