.net - Deserialize into same object using JsonConvert (c#) -


i have method in class uses api data. next use jsonconvert.deserializeobject create instance of same class, copy values object i'm in, wanted values in first place. although works fine, seems there must better way this. (i know further refactored srp. i'm trying find more efficient way values members.)

can show me better way?

         public class mymodel          {             public string description { get; set; }             public string last_name { get; set; }             public string nickname { get; set; }               public void load()             {                 var results = {code gets stuff}                 mymodel item = jsonconvert.deserializeobject<mymodel>(results.tostring());                  this.description = item.description;                 this.last_name = item.last_name;                 this.nickname = item.nickname;             }             .             .             .           } 

do want this

class         {             public int id { get; set; }              public string value { get; set; }              public void load()             {                 var json = @"{id:1,value:""value""}";                 jsonconvert.populateobject(json, this);             }         } 

Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -