Skip to content

Instantly share code, notes, and snippets.

Console.WriteLine("Hello, World!");
Console.ReadLine();
@DaveVdE
DaveVdE / gist:3428319
Created August 22, 2012 18:50
The configuration...
// Who needs XML anyway?
HttpConfiguration configuration = GlobalConfiguration.Configuration;
configuration.Formatters.Remove(configuration.Formatters.XmlFormatter);
configuration.Formatters.Remove(configuration.Formatters.JsonFormatter);
configuration.Formatters.Add(new MyJsonMediaTypeFormatter());
@DaveVdE
DaveVdE / gist:3428304
Created August 22, 2012 18:48
MyJsonMediaTypeFormatter
public class MyJsonMediaTypeFormatter : JsonMediaTypeFormatter
{
public override System.Threading.Tasks.Task WriteToStreamAsync(System.Type type, object value, System.IO.Stream writeStream, System.Net.Http.HttpContent content, System.Net.TransportContext transportContext)
{
var obj = new {d = value};
return base.WriteToStreamAsync(type, obj, writeStream, content, transportContext);
}
}