I am attempting to parse some JSON that has a known top level schema. However inside the schema is one JSON object that can contain various types of JSON objects.
Example
{
"knownfield1": data,
"knownfield2": data,
"knownfieldcollection":
{
"fieldofunknowntype1": "string data",
"fieldofunknowntype2":
{
"subunknownfield1": "string data",
"subunknownfield1": null
},
"fieldofunknowntype3": null
}
}
I would like to make an object that contains a mapping of the known fields, but can read the unknown fields in dynamically. I was trying with Json.Net JToken and JObject, but I could not get it to work. I kept getting recursive JToken exceptions.
Any pointers on this would be great. Thank you.
Exception I am getting:
Type 'Newtonsoft.Json.Linq.JToken' is a recursive collection data
contract which is not supported. Consider modifying the definition of
collection 'Newtonsoft.Json.Linq.JToken' to remove references to itself.
--edit-- Mistyped Collection for object, fixed that.