Microsoft.Azure.Cosmos.Spatial.Point is not compatible with UseSystemTextJsonSerializerWithOptions or System.Text.Json #4744
Labels
bug
Something isn't working
customer-reported
Issue created by a customer
good first issue
Good for newcomers
Describe the bug
When creating an item using CreateItemAsync which contains a property of type Microsoft.Azure.Cosmos.Spatial.Point the property is not serialized properly. This only happens when using UseSystemTextJsonSerializerWithOptions or with a custom Serializer which uses System.Text.Json.
The following exception occurs:
Using PatchItemAsync to set a value of type Microsoft.Azure.Cosmos.Spatial.Point updates the document with an improperly serialized value.
To Reproduce
See the following code snippet to reproduce:
Expected behavior
Property of type Microsoft.Azure.Cosmos.Spatial.Point is serialized as follows:
Actual behavior
Property of type Microsoft.Azure.Cosmos.Spatial.Point is serialized as follows:
Environment summary
SDK Version: 3.43.1 on .NET 8
OS Version: Windows 11
Additional context
The same exception occurs if an item was previously serialized as:
Then the item is retrieved using ReadItemAsync.
After some investigation it seems that Microsoft.Azure.Cosmos.Spatial.Point uses Newtonsoft.Json for serialization. I have created a custom System.Text.Json.Serialization.JsonConverter replicating the functionality of the various built-in converters to get around the issue when creating or reading the item, however, when using PatchItemAsync to set a value of Microsoft.Azure.Cosmos.Spatial.Point the converter is ignored because PatchOperation is Newtonsoft.Json all the way down and the value is serialized as follows:
I'm happy to provide any additional information.
The text was updated successfully, but these errors were encountered: