asp.net web api - parsing boolean value with Json -
i'm using json send objects android application web api application. when try send object contains boolean value value deserialized false if true in json ! here exemple :
public class myobject{ public boolean value1; public string value2; }
and have method object server :
public string postobject(string url, object obj) throws parseexception, ioexception { defaulthttpclient client = new defaulthttpclient(); httppost httppost = new httppost(url); stringentity stringentity = new stringentity(new gsonbuilder().setdateformat("yyyy-mm-dd't'hh:mm:ss").create().tojson(obj)); httppost.setentity(stringentity); httppost.setheader("accept", "application/json"); httppost.setheader("content-type", "application/json"); httppost.setheader("accept-encoding", "gzip"); httpresponse httpresponse = client.execute(httppost); httpentity httpentity = httpresponse.getentity(); string resp = entityutils.tostring(httpentity); return resp; }
and here i'm sending object server :
myobject obj = new myobject(); obj.value1 = true; obj.value2 = "testing"; jsonhttpclient jsonhttpclient = new jsonhttpclient(); string response = jsonhttpclient.postobject(myurl, obj);
and here code server side :
[acceptverbs("post")] public string test(myobject obj) { //obj.value1 = false !!! }