Friday, September 9, 2016

Serialize a type as an anonymous type.

Just wrapping the type in curly braces may make it friendly to be handed back as JSON from C# in an ASP.NET Web API paradigm.

var foo = new Foo() { Whatever = "Whatever" };
return new { foo };

No comments:

Post a Comment