ServiceStack/ServiceStack.Text — pull request #60 by danielwertheim (2012-01-26 19:17:43+00:00)
Title: Support for deserializing to anonymous types

Added a setting and code for supporting deserialization of json to an anonymous type.

`TypeConfig.EnableAnonymousFieldSetters = true;`

Only tested in .Net 4.0 and maybe there could be better conventions for locating the field: https://github.com/danielwertheim/ServiceStack.Text/blob/6223a9adf4e83c99b8ce76be1b4ab4df72ed2bd3/src/ServiceStack.Text/Common/DeserializeType.cs#L150

This means that e.g an extension method like this could be provided.

`c#
public static T DeserializeToAnonymousType(this JsonSerializer serializer, T template, string json) where T : class
{
TypeConfig.EnableAnonymousFieldSetters = true;
return serializer.DeserializeFromString(json, template.GetType()) as T;
}
`