How to remove null object in json object in mvc Web API 2
C# code using Web API 2
public HttpResponseMessage Login(Login obj)
{
string pass = obj.Password;
obj.Password = ec.Encrypt(pass);
objResponse = objbll.UserLogin(obj);
string Json = JsonConvert.SerializeObject(objResponse);
var response = Request.CreateResponse(HttpStatusCode.OK);
response.Content = new StringContent(Json, Encoding.UTF8, "application/json");
return response;
}
my Result is
{
"Status": true,
"StatusCode": "200",
"Message": "Congratulation ! username & password has been matched ! ",
"Title": "",
"Data": {
"UserId": "32",
"UserName": "sajid",
"Password": null, (remove this line)
"UserType": "2",
"Databasename": "db_fmcgv2x3_rahultradres_online"
}
}