If the class consists of simple JSON-compatible types, MyClass obj = JsonConvert.DeserializeObject<MyClass>(JSONtext);
does the job quite nicely. If MyClass contains enum or struct properties, the DeserializeObject<> method returns null. I'm currently iterating through the JSON response deserialized into a JObject, assigning values to the inner class created, and returning it. Is there a better way to deserialize the JSON string into an heterogeneous class object?
class MyClass
{
public Int32 wishlistID;
public Basket currentBasket; //struct
public List<Int32> items;
public dStatus _dStatus; //enum
}
Edit: turns out that, for some reason, all Basket's properties had the private modifier; of course they couldn't be accessed and result to be therefore null. Switching it to public did the trick.