Skip to content

[VNext] System.Text.Json as default serializer #2533

@kirankumarkolli

Description

@kirankumarkolli

CosmosClient supports customizing the serializers #CosmosLinqSerializer.

NOTE: CosmosSerializer will be deprecated in future, prefer CosmosLinqSerializer

CosmosClient library includes two implementations for JSON.net and System.Text.Json (https://learn.microsoft.com/en-us/dotnet/api/system.text.json) with JSON.net being the default serializer.

Applications can change the default to System.Text.Json through CosmosClientOptions

            CosmosClientOptions options = new CosmosClientOptions()
            {
                UseSystemTextJsonSerializerWithOptions = new System.Text.Json.JsonSerializerOptions()
                {
                    PropertyNamingPolicy = System.Text.Json.JsonNamingPolicy.CamelCase,
                }
            };

            CosmosClient client = new(
                ...,
                options
            );

This work item is to change the default to System.Text.json for next major version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    VNextNext Major version of SDKfeature-requestNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions