-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathDefaultSourceSerializer.cs
30 lines (27 loc) · 1.08 KB
/
DefaultSourceSerializer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Elastic.Clients.Elasticsearch.Serialization;
internal class DefaultSourceSerializer : SystemTextJsonSerializer
{
public DefaultSourceSerializer(IElasticsearchClientSettings settings, JsonSerializerOptions? options = null) =>
Options = options ?? new JsonSerializerOptions
{
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
Converters =
{
new JsonStringEnumConverter(),
new UnionConverter(),
new IdConverter(settings),
new RelationNameConverter(settings),
new RoutingConverter(settings),
new JoinFieldConverter(settings),
new LazyJsonConverter(settings),
new IdsConverter(settings)
},
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.AllowNamedFloatingPointLiterals
};
}