c# - RestSharp RestRequest.AddBody not using Newton.Json attributes -


var obj = new myobject(); 

i having issue getting restsharp restrequest.addbody(obj); serialize object correctly.

class myobject {    [jsonproperty(propertyname="a")]    public a{get;set;}     [jsonproperty(propertyname="b")]    public b{get;set;} } 

problem addbody serializer not taking account jsonproperty attributes , can seem figure out how set serializer on restrequest or restclient?

i have used answer of tafaju , implemented serializer json this.

public class customjsonserializer : iserializer {     public customjsonserializer()     {         contenttype = "application/json";     }      public string serialize(object obj)     {         return jsonconvert.serializeobject(obj);     }      public string rootelement { get; set; }      public string namespace { get; set; }      public string dateformat { get; set; }      public string contenttype { get; set; }  } 

and works me, reads attributes , serializes types correctly. didn't test types. documentation says rootelement, namespace, dateformat aren't used json.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -