Code
·
18 lines
·
614 bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18using MongoDB.Bson;
using System.Text.Json.Serialization;
using System.Text.Json;
namespace BsonExtensions.Converters;
public class BsonDocumentsJsonConverter : JsonConverter<List<BsonDocument>>
{
public override List<BsonDocument> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
throw new NotImplementedException();
}
public override void Write(Utf8JsonWriter writer, List<BsonDocument> bsonDocuments, JsonSerializerOptions? options)
{
writer.WriteRawValue(BsonJsonSerializer.ToJson(bsonDocuments, options, BsonJsonSerializer.TypeSerializationEnum.None));
}
}