For completeness, here is the bit of code I was missing.
Because I am sending everything through a WCF service it wants to deal
in strings. You have to explicitely return a stream and simply do
this:
WebOperationContext.Current.OutgoingResponse.ContentType =
"application/json; charset=utf-8";
return new
MemoryStream(Encoding.UTF8.GetBytes(retList.ToJson(settings)));
so the complete code looks like:
public Stream GetBsRobust(string bID, double latitude, double
longitude, double radius)
{
var nearQuery = Query.Near("bLocation", latitude, longitude,
radius);
ObjectId queryId = new ObjectId(bID);
var query = new QueryDocument {
{ "_id", queryId } };
BsonDocument retBs = _bs.FindOne(query);
MongoCursor csrBs = _beeps.Find(nearQuery).SetLimit(10);
var settings = new JsonWriterSettings
{
OutputMode =
JsonOutputMode.Strict
};
List<BsonDocument> retList = new List<BsonDocument>();
foreach (B bs in csrBs)
{
retList.Add(bs.ToBsonDocument());
}
WebOperationContext.Current.OutgoingResponse.ContentType =
"application/json; charset=utf-8";
return new
MemoryStream(Encoding.UTF8.GetBytes(retList.ToJson(settings)));
}
Hope this helps someone!!!