Newtonsoft.Json icon indicating copy to clipboard operation
Newtonsoft.Json copied to clipboard

System.Object is deserialized as JObject

Open kendfrey opened this issue 2 years ago • 1 comments

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)

kendfrey avatar Jul 04 '22 20:07 kendfrey

if deserialized return object ,i think you can do not every thing.

sangeren avatar Oct 12 '23 00:10 sangeren