Skip to content

SystemTextJsonSerializer.Serialize ignores SerializationFormatting #8010

Closed
@VMelnalksnis

Description

@VMelnalksnis

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions