json.net 可以将类对象序列化成一个简单的字典吗?
public class CommitData
{
public AddressDTO Property { get; set; }
public DateTime? Appointment { get; set; }
public DateTime? Closed { get; set; }
public DateTime? Created { get; set; }
public string LenderRef { get; set; }
public string YearBuilt { get; set; }
public IDictionary<string, object> Custom { get; set; }
}
public class AddressDTO
{
public string Address1 { get; set; }
public string Address2 { get; set; }
public string Address3 { get; set; }
public string Town { get; set; }
public string County { get; set; }
public string Postcode { get; set; }
}
序列化时我想得到:
{
"Property.Address1": "",
"Property.Address2": "uyg",
"LenderRef": "yguyg",
"Closed": date_here
}
并且类似地将上面的 json 字符串反序列化到 CommitData 对象中?