Azure / azure-cosmos-dotnet-v3

.NET SDK for Azure Cosmos DB for the core SQL API
MIT License
723 stars 477 forks source link

Add client option to use the System.Text.Json Serializer instead of Newtonsoft ... #4540

Closed bdcoder2 closed 2 weeks ago

bdcoder2 commented 2 weeks ago

When creating a Cosmos DB client, allow an option that will use the System.Text.Json serializer instead of Newtonsoft.

As per the StackOverflow question: https://stackoverflow.com/questions/78604777/why-is-azure-cosmosdb-saving-dictionary-object-values-as-valuekind-number.

Instead of incorporating code as per the answer given in the question above, provide a client option that automatically uses the System.Text.Json serializer, for example, an option such as:

UseSystemTextJson = true

When the option is true, the "Serializer" can be set internally using the code from: https://github.com/Azure/azure-cosmos-dotnet-v3/tree/master/Microsoft.Azure.Cosmos.Samples/Usage/SystemTextJson

This simple change would allow us to use the System.Text.Json serializer with the Cosmos SDK (v3) without having to manually incorporate the code above.

Thank-you for your consideration.

bartelink commented 2 weeks ago

See #4330 (I basically asked for this in https://github.com/Azure/azure-cosmos-dotnet-v3/issues/4325)

Pilchie commented 2 weeks ago

Duplicate of #4330