-
Notifications
You must be signed in to change notification settings - Fork 495
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
Add support for JSON.net JsonSerializerSettings #551
Comments
It would also be nice to have a sample showing a simple change to the default serializer. Without official documentation or a sample I don't even know what I don't know. Having to dig through source code and tests is painful |
@nheinbaugh thanks for the suggestion. I created an issue to track it #559 |
Until Microsoft exposes the serializer settings, you could just take the code of the default CosmosJsonSerializer and pass in a JsonSerializerSettings. Example gist: https://gist.github.com/richstokoe/c82fc831c6b4020926f5b5f772f7cd70 |
@richstokoe that is the current plan. That is why this issue was created. |
Sure, and I didn't mean to hinder that, just wanted to show that open source means we don't always have to wait for the samples. Keep going, v3 SDK is awesome. |
@richstokoe 3.1.0 is now released with the new serializer |
@richstokoe and @nheinbaugh can you please take a look at this PR #650? We need to remove the CosmosJsonDotNetSerializer. The Azure central SDK team has guideline that we need to move to the new system.text.json, and exposing the JSON settings directly conflicts with that. This PR add supports for some common JSON settings. Does this support all of your scenarios? |
@j82w Thanks for the engagement! |
@richstokoe camel case refers to the first character being lower case. Pascal case is where the first character is capitalized. Check out Camel Case vs Pascal Case. I don't see an option in Newtonsoft or system.text.JSON that support pascal case by default. They both would require a custom converter. Do you have any requirements to support pascal case? |
The final solution with cosmos serialization settings it merged. |
Is there support for customer converts with the current setup? I am looking to add a stringtoenumconverter. |
Hi @adstep , To support a custom converter you will need to implement a CosmosSerializer that is set on the CosmosClientOptions. You can take a look @richstokoe implementation to see an example. |
To be honest, I'm not very happy with the current solution. I understand that you don't want to explicitly depend on JSON.NET, but since there's a package reference, you depend on it anyway. I think a good approach would be the following:
|
@thomaslevesque 's suggestion will also lead to a thriving STJ implementation sitting alongside it in a matter of days, methinks. |
To override a single JsonSerializerSettings requires implementing an entire serializer class. There should be a way to override the default serializer settings to avoid forcing users to create a entire new class just for one setting.
The text was updated successfully, but these errors were encountered: