Jun 15, 2012 at 12:35 AM
Edited Jun 15, 2012 at 12:37 AM
|
I'm so happy to see Json.NET being baked into Web API, however, I still have to write my own custom MediaTypeFormatter to support Bson. Json.NET supports this very easily using the same JsonSerializer.
Something like:
if (contentHeaders.ContentType.MediaType.Equals("application/bson", StringComparison.InvariantCultureIgnoreCase))
{
// using new BsonWriter(stream) ... Serialize(bsonWriter, ...)
}
else
{ // using new JsonTextWriter(new StreamWriter(stream)) ... Serialize(jsonTextWriter, ...
}
private static void Serialize(JsonWriter jsonWriter, Object instance, JsonSerializerSettings serializerSettings)
Bson uses the same JsonSerializer / JsonSerializerSettings. BsonReader and BsonWriter inherit from JsonReader JsonWriter respectively.
Please consider adding this support. Thanks!
|
|
|
|
Not a bad idea -- please log an issue so that we can track.
Henrik
[1] http://aspnetwebstack.codeplex.com/workitem/list/advanced
|
|
|
|
Thanks for the consideration Henrik. I've created an issue: http://aspnetwebstack.codeplex.com/workitem/241
|
|