Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SystemTextJsonSerializer.Serialize ignores SerializationFormatting #8010

Closed
VMelnalksnis opened this issue Jan 10, 2024 · 1 comment · Fixed by #8143
Closed

SystemTextJsonSerializer.Serialize ignores SerializationFormatting #8010

VMelnalksnis opened this issue Jan 10, 2024 · 1 comment · Fixed by #8143
Labels
8.x Relates to 8.x client version Area: Client Category: Bug

Comments

@VMelnalksnis
Copy link

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:

  1. Call DefaultSourceSerializer.Serialize<T> with SerializationFormatting.Indented
  2. See that JSON is in single line

Expected behavior
JSON formatting follows specified SerializationFormatting.

@VMelnalksnis VMelnalksnis added the 8.x Relates to 8.x client version label Jan 10, 2024
@flobernd flobernd added the bug label Jan 15, 2024
@flobernd
Copy link
Member

Thanks for reporting!

Seems like we forgot to pass custom JsonWriterOptions to the Utf8JsonWriter constructor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.x Relates to 8.x client version Area: Client Category: Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants