NET MVC Web API's, i created a class of Response so that All Routes return same response pattern,
[DataContract]
public class Response
{
[DataMember]
public string ResponseMessage { get; set; }
[DataMember]
public int ResponseCode { get; set; }
[DataMember]
public object ResponsePayload { get; set; }
}
I am calling APIResponse Method from All routes to return Response, Every time i would Pass Either DataTable or DataSet in object responseObj param of below function, I have to use ADO.NET DB Access layer, :)
private Object APIResponse(object responseObj, string _message = Constants.RESPONSE_MESSAGE_SUCCESS, int code = _RESPONSE_SUCCESS_CODE)
{
Response _response = new Response();
_response.ResponsePayload = responseObj;
_response.ResponseMessage = _message;
_response.ResponseCode = code;
return Newtonsoft.Json.JsonConvert.SerializeObject(_response);
}
if my responseObj param is of type DataSet, than i get Unwanted Quotes and Backslashes (Like in PHP if Magic Quotes are enable on Server) which produce a invalid JSON, Can you please help me in fixing this issue, to remove these slashes,
Sample JSON:
"{\"ResponseMessage\":\"Success\",\"ResponseCode\":200,\"ResponsePayload\":{\"StatusList\":[{\"StatusId\":1,\"Status\":\"To Be Dispatched\", ...........