Newtonsoft.Json
Newtonsoft.Json copied to clipboard
System.Object is deserialized as JObject
Source/destination types
// N/A
Source/destination JSON
{"$type":"System.Object, System.Private.CoreLib"}
Expected behavior
A value of type object
should be deserialized as an instance of object
.
Actual behavior
A value of type object
is deserialized as an instance of JObject
.
Steps to reproduce
var settings = new JsonSerializerSettings()
{
TypeNameHandling = TypeNameHandling.All,
};
var json = JsonConvert.SerializeObject(new object(), settings);
var obj = JsonConvert.DeserializeObject(json, settings);
// obj.GetType() returns typeof(JObject) instead of typeof(object)
if deserialized return object ,i think you can do not every thing.