.NET Web API – Transform dynamic result to JSON

protected HttpResponseMessage JsonApiRespond(dynamic input)
 {
  string jsonResult = JsonConvert.SerializeObject(input, _jsonSettings);
  HttpResponseMessage response = this.Request.CreateResponse(HttpStatusCode.OK);
  response.Content = new StringContent(jsonResult, Encoding.UTF8, "application/json");
  return response;
 }


Author: Alex T. Silverstein

A developer who wants to help you and himself by writing down good tidbits for free

Leave a Reply

Your email address will not be published. Required fields are marked *