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

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -