I am trying to create a .NET object from JObject, but I get all the properties of the object as default values ββ(null for string, 0 for int, etc.)
I create a simple Jobject:
var jsonObject = new JObject(); jsonObject.Add("type", "Fiat"); jsonObject.Add("model", 500); jsonObject.Add("color", "white");
Car class:
public class Car { string type {get;set;} int model {get ;set;} string color {get;set;} }
deserialization here:
Car myCar = jsonObject.ToObject<Car>();
But the result at runtime is the default values: Runtime Image
I would like to know why this is happening and how I should do it right,
thanks
source share