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.
2
Answers
Here is the solution I found thanks to your help:
And there is how to use it:
you can create a custom json converter