I just got a hold of JSON.NET and its been great so far.
However, I cannot figure out how to determine the type of a serialized object when
it may help you
IDictionary < string, JToken > Jsondata = JObject.Parse(yourJsonString);
foreach(KeyValuePair < string, JToken > element in Jsondata)
{
string innerKey = element.Key;
if (element.Value is JArray)
{
// Process JArray
}
else if (element.Value is JObject)
{
// Process JObject
}
}
you can use dynamic type
JsonConvert.DeserializeObject<dynamic>(JSONtext)
In case you control the serialization, you can use the TypeNameHandling setting
var settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All };
var toBeSerialized = settings; // use the settings as an example data to be serialized
var serialized = JsonConvert.SerializeObject(toBeSerialized, Formatting.Indented, settings);
var deserialized = JsonConvert.DeserializeObject(serialized, settings);
var deserializedType = deserialized.GetType().Name; // JsonSerializerSettings