I have an object which need to be serialized.
Object to serialize:
public class Setting
{
// Exclude from serialization
private SettingInfo _key;
public SettingInfo Key
{
get { return _key; }
set
{
_key = value;
Key_Id = _key == null ? 0 : _key.Id;
}
}
// Need to be serialized
public int Key_Id { get; set; }
public string Value { get; set; }
}
Question:
Is it possible to exclude the SettingInfo object (Property Key) from serialization using DynamicJson?
- I am using
DynamicJson - Current result: (which contains the serialized
Keyproperty)
{"Key":{"Id":20,"Type":"System.String","Name":"ExampleSetting"},
"Key_Id":20,
"Value":"New Value"} - Requested result:
{"Key_Id":20,"Value":"New Value"}