elasticsearch-net
elasticsearch-net copied to clipboard
SystemTextJsonSerializer.Serialize ignores SerializationFormatting
Elastic.Clients.Elasticsearch version: 8.11.0
Elasticsearch version: -
.NET runtime version: 8.0.100
Operating system version: -
Description of the problem including expected versus actual behavior:
Unlike SerializeAsync<T>
, Serialize<T>
creates a new Utf8JsonWriter
, which has its own JsonWriterOptions
, which ignore JsonSerializerOptions
. If SerializationFormatting.Indented
, JsonWriterOptions
still defaults to Indented = false
.
Steps to reproduce:
- Call
DefaultSourceSerializer.Serialize<T>
withSerializationFormatting.Indented
- See that JSON is in single line
Expected behavior
JSON formatting follows specified SerializationFormatting
.
Thanks for reporting!
Seems like we forgot to pass custom JsonWriterOptions
to the Utf8JsonWriter
constructor.