public static void JsonContent(this HttpListenerResponse response, object contentObject) { var jsonText = SimpleJson.SerializeObject(contentObject); //doesn't work for dynamic //var jsonText JsonConvert.SerializeObject(contentObject); //handles dynamic response.ContentType("application/json").Content(jsonText); }
public static void JsonTextContent(this HttpListenerResponse response, string value) { response.ContentType("application/json"); var buffer = Encoding.UTF8.GetBytes(value); response.ContentLength64 += buffer.Length; response.OutputStream.Write(buffer, 0, buffer.Length); }
public static void JsonContent(this HttpListenerResponse response, object contentObject) { var jsonText = JsonConvert.SerializeObject(contentObject); response.ContentType("application/json").Content(jsonText); }