-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Expose ability to customize JSON serialization #5050
Comments
After reading the following blog post: https://devblogs.microsoft.com/cosmosdb/difference-between-null-and-undefined/ I was wondering how to achieve this with the Java SDK. I was stumbling across this when adding a But if I set the
The documentation here states that setting |
@kushagraThapar I'd like to see some solution here, as this really limits some advanced use cases of the SDK. So maybe you can move it out of the "parking lot" again and assign it a higher prio? For example, you cannot use Kotlin classes out-of-the-box as https://github.com/FasterXML/jackson-module-kotlin is not registered in the static ObjectMapper hidden in the SDK. This forces you to annotate Kotlin classes manually as a very ugly workaround to get deserialization of immutable data classes working: data class Email @JsonCreator constructor(
@param:JsonProperty("email") val email: String // note the redundant specification of "email"
) Or do some hack like calling For @dkroehan a workaround would be to use |
@xinlian12 - thoughts on this issue ? |
I don't know if this is still being actively looked into, but there is an example of this in
There are two implementation packages for |
@alzimmermsft Without having looked into details, am I getting it right that using a custom |
It would be the former, where some libraries offer support for As additional context |
Bumping this thread. I have run into an issue where the Cosmos SDK failed to serialize a LocalDate within a repository query (resulting in a missing jsr310 module exception). I tried the hack that neiser mentioned above which partially resolved things, but would rather let the customer specify their own serializer as they can with the ACS SDK as mentioned by alzimmermsft. Happy to open a new issue to track, if that makes sense. |
@mmcdermottMS - FYI, I have recently added the jsr310 module to Java SDK. You should be able to leverage it in the latest release of azure-cosmos Java V4 SDK. |
Hi, I think this is a related-enough issue to post it here: I'm struggling using GeoJson points in Spring Data for Cosmos. It looks like there's a class designed for just plugging in and using, I wrote a terrible hack using reflection to call the GeoJsonSerializer.getModule() anyway to use while defining my cosmosObjectMapper (though I don't know if I actually want to check it in), but it seems like having the SDK expose better options for customizing is really the way to go here. Thanks. I'm using spring-cloud-azure-starter-data-cosmos 4.4.1 with Java 11. |
@petercooperjr-spls - I think it would be better to create a separate issue for the problem you are facing. We can better investigate it that way. |
Another hack would be to use your own serializer and persist the json tree. val jsonTree = myObjectMapper.valueToTree<JsonNode>(myKtDataClass)
val itemResponse = cosmosContainer.createItem(jsonTree) |
Just wanted to update this issue, we are building functionality to customize JSON serializability - #38997 Apologize for the delay in this development of this feature. |
Hi @christopheranderson, we deeply appreciate your input into this project. Regrettably, this issue has remained unresolved for over 2 years and inactive for 30 days, leading us to the decision to close it. We've implemented this policy to maintain the relevance of our issue queue and facilitate easier navigation for new contributors. If you still believe this topic requires attention, please feel free to create a new issue, referencing this one. Thank you for your understanding and ongoing support. |
This has been done. Implementation details in this PR - #38997 |
Removed public ObjectMapper references which let users customize JSON serialization.
This was due to Azure/azure-cosmosdb-java#153 need a better option.
The text was updated successfully, but these errors were encountered: