Deserialized Object Has All Values Set to Null
in my case it was because of my destination type have internal (or private) set modifiers for those properties .
public class Summary{
public Class2 Prop1 { get; internal set; }
public Class1 prop2 { get; set; }
}
after removing internal modifier, json.net deserialize those objects too like the serialization step
Your JSON has an outer object which contains a collection of Key objects. The following code works (I tested it):
class KeyWrapper
{
public List<Key> Keys { get; set; }
}
class Key
{
public string RegistrationKey { get; set; }
public string ValidationStatus { get; set; }
public string ValidationDescription { get; set; }
public List<Properties> Properties { get; set; }
}
public class Properties
{
public string Key { get; set; }
public string Value { get; set; }
}
public void DeserializeKeys()
{
const string json = @"{""Keys"":
[
{
""RegistrationKey"": ""asdfasdfa"",
""ValidationStatus"": ""Valid"",
""ValidationDescription"": null,
""Properties"": [
{
""Key"": ""Guid"",
""Value"": ""i0asd23165323sdfs68661358""
}
]
}
]
}";
var keysWrapper = Newtonsoft.Json.JsonConvert.DeserializeObject<KeyWrapper>(json);
}