c# - Json serialization variable PropertyName -
i use c# , newtonsoft.json library serialization , deserialization of json.
i have class this
public class animal { [jsonproperty(propertyname = "dog")] public key value {get;set;} }
if instantiate as
animal = new animal{ key = "bobby" };
and serialize i'll have json like
{ "dog": "bobby" }
can change propertyname of serialization dynamically? instance, if want put "bird" or "cat" instead of "dog"?
public class animal { public keyvaluepair<string,string> value {get;set;} } animal = new animal { value = new keyvaluepair("dog","boddy")};
if want bird
animal = new animal { value = new keyvaluepair("bird","bird1")};
Comments
Post a Comment